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:
Yehuda Katz
2013-07-26 16:50:37 +00:00
parent f5c8484ea0
commit 5f664dd78b
8 changed files with 70 additions and 61 deletions
+3 -3
View File
@@ -5,11 +5,11 @@ global.Handlebars = require('../../dist/handlebars.runtime');
var compiler = require('../../lib/handlebars');
global.CompilerContext = {
compile: function(template, options) {
compile: function(template, options, env) {
var templateSpec = compiler.precompile(template, options);
return Handlebars.template(eval('(' + templateSpec + ')'));
return Handlebars.template(eval('(' + templateSpec + ')'), env);
},
compileWithPartial: function(template, options) {
compileWithPartial: function(template, options, env) {
return compiler.compile(template, options);
}
};