Make the Handlebars environment into an object
The idea is that the environment wraps up the mutable stuff in Handlebars (like the helpers) and that you could theoretically create a new one at any time and pass it in to Handlebars.template. Every test makes a new environment and uses it in template compilation.
This commit is contained in:
Vendored
+5
-3
@@ -3,12 +3,14 @@ require('./common');
|
||||
global.Handlebars = require('../../zomg/lib/handlebars');
|
||||
|
||||
global.CompilerContext = {
|
||||
compile: function(template, options) {
|
||||
compile: function(template, options, env) {
|
||||
env = env || handlebarsEnv;
|
||||
var templateSpec = Handlebars.precompile(template, options);
|
||||
console.log(templateSpec);
|
||||
return Handlebars.template(eval('(' + templateSpec + ')'));
|
||||
return Handlebars.template(eval('(' + templateSpec + ')'), env);
|
||||
},
|
||||
compileWithPartial: function(template, options) {
|
||||
options = options || {};
|
||||
options.env = handlebarsEnv;
|
||||
return Handlebars.compile(template, options);
|
||||
}
|
||||
};
|
||||
|
||||
Reference in New Issue
Block a user