diff options
author | Yehuda Katz <wycats@gmail.com> | 2013-07-26 16:50:37 +0000 |
---|---|---|
committer | Yehuda Katz <wycats@gmail.com> | 2013-07-26 16:50:37 +0000 |
commit | 5f664dd78b2c558a8a560b3fd0074109d52daf62 (patch) | |
tree | 16a72bc0c85699e95bed94c927a8ab2586617ece /lib/handlebars/compiler/compiler.js | |
parent | f5c8484ea0c1ac1aec6994ad3b5928fb67b7aa62 (diff) | |
download | handlebars.js-5f664dd78b2c558a8a560b3fd0074109d52daf62.zip handlebars.js-5f664dd78b2c558a8a560b3fd0074109d52daf62.tar.gz handlebars.js-5f664dd78b2c558a8a560b3fd0074109d52daf62.tar.bz2 |
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.
Diffstat (limited to 'lib/handlebars/compiler/compiler.js')
-rw-r--r-- | lib/handlebars/compiler/compiler.js | 6 |
1 files changed, 3 insertions, 3 deletions
diff --git a/lib/handlebars/compiler/compiler.js b/lib/handlebars/compiler/compiler.js index b779617..6656a3f 100644 --- a/lib/handlebars/compiler/compiler.js +++ b/lib/handlebars/compiler/compiler.js @@ -443,17 +443,17 @@ export function compile(input, options) { var compiled; - function compile() { + function compileInput() { var ast = parse(input); var environment = new Compiler().compile(ast, options); var templateSpec = new JavaScriptCompiler().compile(environment, options, undefined, true); - return template(templateSpec); + return template(templateSpec, options.env || Handlebars, compile); } // Template is only compiled on first use and cached after that point. return function(context, options) { if (!compiled) { - compiled = compile(); + compiled = compileInput(); } return compiled.call(this, context, options); }; |