diff options
author | Blake Embrey <hello@blakeembrey.com> | 2013-12-28 21:35:40 -0500 |
---|---|---|
committer | Blake Embrey <hello@blakeembrey.com> | 2013-12-28 21:35:40 -0500 |
commit | 2f0c96b61873ce3b729c2d13ff8ae719608c1d40 (patch) | |
tree | f898aa90f50fa2c708e2f8f0b7e4d3f8fcecfbc0 /lib/handlebars/compiler/compiler.js | |
parent | 6c2137a420aa1007dfed85db88021e09ddc66a04 (diff) | |
download | handlebars.js-2f0c96b61873ce3b729c2d13ff8ae719608c1d40.zip handlebars.js-2f0c96b61873ce3b729c2d13ff8ae719608c1d40.tar.gz handlebars.js-2f0c96b61873ce3b729c2d13ff8ae719608c1d40.tar.bz2 |
Make the environment reusable.
Diffstat (limited to 'lib/handlebars/compiler/compiler.js')
-rw-r--r-- | lib/handlebars/compiler/compiler.js | 21 |
1 files changed, 9 insertions, 12 deletions
diff --git a/lib/handlebars/compiler/compiler.js b/lib/handlebars/compiler/compiler.js index daea307..259c543 100644 --- a/lib/handlebars/compiler/compiler.js +++ b/lib/handlebars/compiler/compiler.js @@ -1,7 +1,4 @@ import Exception from "../exception"; -import { parse } from "./base"; -import JavaScriptCompiler from "./javascript-compiler"; -import AST from "./ast"; export function Compiler() {} @@ -423,8 +420,8 @@ Compiler.prototype = { } }; -export function precompile(input, options) { - if (input == null || (typeof input !== 'string' && input.constructor !== AST.ProgramNode)) { +export function precompile(input, options, env) { + if (input == null || (typeof input !== 'string' && input.constructor !== env.AST.ProgramNode)) { throw new Exception("You must pass a string or Handlebars AST to Handlebars.precompile. You passed " + input); } @@ -433,13 +430,13 @@ export function precompile(input, options) { options.data = true; } - var ast = parse(input); - var environment = new Compiler().compile(ast, options); - return new JavaScriptCompiler().compile(environment, options); + var ast = env.parse(input); + var environment = new env.Compiler().compile(ast, options); + return new env.JavaScriptCompiler().compile(environment, options); } export function compile(input, options, env) { - if (input == null || (typeof input !== 'string' && input.constructor !== AST.ProgramNode)) { + if (input == null || (typeof input !== 'string' && input.constructor !== env.AST.ProgramNode)) { throw new Exception("You must pass a string or Handlebars AST to Handlebars.compile. You passed " + input); } @@ -452,9 +449,9 @@ export function compile(input, options, env) { var compiled; function compileInput() { - var ast = parse(input); - var environment = new Compiler().compile(ast, options); - var templateSpec = new JavaScriptCompiler().compile(environment, options, undefined, true); + var ast = env.parse(input); + var environment = new env.Compiler().compile(ast, options); + var templateSpec = new env.JavaScriptCompiler().compile(environment, options, undefined, true); return env.template(templateSpec); } |