Secure your code as it's written. Use Snyk Code to scan source code in minutes - no build needed - and fix issues immediately.
function compileTemplate(source, config = {}) {
const { modules = {} } = config;
// Check if the same template has already been compiled
if (!(source in TEMPLATE_CACHE)) {
TEMPLATE_CACHE[source] = compileToFunction(source);
}
const templateFactory = TEMPLATE_CACHE[source];
return registerTemplate(templateFactory(modules));
}