consolidate.js
consolidate.js copied to clipboard
data property is being overwritten
I originally opened this in handlebars.js (see https://github.com/wycats/handlebars.js/issues/1327 for more background). With more digging, we discovered the issue is due to the fact that in node_modules/consolidate/lib/consolidate.js
you are passing "options" (which is the data for the template) into the engine.compile()
method as well as the tmpl()
method:
var tmpl = cache(options) || cache(options, engine.compile(str, options));
fn(null, tmpl(options));
The official way to use the plugin is something like:
var template = Handlebars.compile(tplStr, tplOpt);
document.getElementById('output').innerHTML = template(tplData);
where the data for the template is not also passed as the options for the compile method.
@nknapp https://github.com/nknapp said he would look into why compile
is altering the options, and he thought you guys could look into why the template data is doubling for the options.