Secure your code as it's written. Use Snyk Code to scan source code in minutes - no build needed - and fix issues immediately.
async run(context, target, ...args) {
const callback = args.pop();
const data = args.shift() || {};
const opts = args.shift() || {};
try {
const [name, ext] = target.split('.');
const variant = lookup(name, context.env.components);
if (!variant) {
throw new Error(`Component extension - Could not find '${name}'`);
}
target = variant;
opts.ext = opts.ext || (ext ? `.${ext}` : null);
const result = await context.env.fractal.render(target, data, opts);
callback(null, new SafeString(result));
} catch (err) {
callback(err);
}
}
};
environment.env.renderString(body(), environment.ctx, (err, html) => {
if (err) {
console.log(err);
return done(err);
}
done(null, new SafeString(html));
});
};
env.render(component.name, props, (err, result) => {
if (err) {
return callback(err);
}
callback(null, new SafeString(result));
});
}
env.render(name, tplData, (err, result) => {
if (err) {
return callback(err);
}
callback(null, new SafeString(result));
});
}
module.exports = async function render(target, args, ui) {
let html = await ui.app.render(target, ...args);
html = ui.utils.resolveUrlRefs(html);
return new SafeString(html);
};