1
1
import Exception from "../exception" ;
2
- import { parse } from "./base" ;
3
- import JavaScriptCompiler from "./javascript-compiler" ;
4
- import AST from "./ast" ;
5
2
6
3
export function Compiler ( ) { }
7
4
@@ -423,8 +420,8 @@ Compiler.prototype = {
423
420
}
424
421
} ;
425
422
426
- export function precompile ( input , options ) {
427
- if ( input == null || ( typeof input !== 'string' && input . constructor !== AST . ProgramNode ) ) {
423
+ export function precompile ( input , options , env ) {
424
+ if ( input == null || ( typeof input !== 'string' && input . constructor !== env . AST . ProgramNode ) ) {
428
425
throw new Exception ( "You must pass a string or Handlebars AST to Handlebars.precompile. You passed " + input ) ;
429
426
}
430
427
@@ -433,13 +430,13 @@ export function precompile(input, options) {
433
430
options . data = true ;
434
431
}
435
432
436
- var ast = parse ( input ) ;
437
- var environment = new Compiler ( ) . compile ( ast , options ) ;
438
- return new JavaScriptCompiler ( ) . compile ( environment , options ) ;
433
+ var ast = env . parse ( input ) ;
434
+ var environment = new env . Compiler ( ) . compile ( ast , options ) ;
435
+ return new env . JavaScriptCompiler ( ) . compile ( environment , options ) ;
439
436
}
440
437
441
438
export function compile ( input , options , env ) {
442
- if ( input == null || ( typeof input !== 'string' && input . constructor !== AST . ProgramNode ) ) {
439
+ if ( input == null || ( typeof input !== 'string' && input . constructor !== env . AST . ProgramNode ) ) {
443
440
throw new Exception ( "You must pass a string or Handlebars AST to Handlebars.compile. You passed " + input ) ;
444
441
}
445
442
@@ -452,9 +449,9 @@ export function compile(input, options, env) {
452
449
var compiled ;
453
450
454
451
function compileInput ( ) {
455
- var ast = parse ( input ) ;
456
- var environment = new Compiler ( ) . compile ( ast , options ) ;
457
- var templateSpec = new JavaScriptCompiler ( ) . compile ( environment , options , undefined , true ) ;
452
+ var ast = env . parse ( input ) ;
453
+ var environment = new env . Compiler ( ) . compile ( ast , options ) ;
454
+ var templateSpec = new env . JavaScriptCompiler ( ) . compile ( environment , options , undefined , true ) ;
458
455
return env . template ( templateSpec ) ;
459
456
}
460
457
0 commit comments