Files
handlebars.js/spec/env/node.js
T
2026-04-21 22:02:44 +03:00

26 lines
659 B
JavaScript

import './common.js';
import Handlebars from '../../lib/index.js';
global.Handlebars = Handlebars;
global.CompilerContext = {
compile: function (template, options) {
var templateSpec = handlebarsEnv.precompile(template, options);
return handlebarsEnv.template(safeEval(templateSpec));
},
compileWithPartial: function (template, options) {
return handlebarsEnv.compile(template, options);
},
};
function safeEval(templateSpec) {
/* eslint-disable no-eval, no-console */
try {
return eval('(' + templateSpec + ')');
} catch (err) {
console.error(templateSpec);
throw err;
}
/* eslint-enable no-eval, no-console */
}