@@ -756,10 +756,21 @@ Handlebars.precompile = function(string, options) {
|
||||
Handlebars.compile = function(string, options) {
|
||||
options = options || {};
|
||||
|
||||
var ast = Handlebars.parse(string);
|
||||
var environment = new Handlebars.Compiler().compile(ast, options);
|
||||
var templateSpec = new Handlebars.JavaScriptCompiler().compile(environment, options, undefined, true);
|
||||
return Handlebars.template(templateSpec);
|
||||
var compiled;
|
||||
function compile() {
|
||||
var ast = Handlebars.parse(string);
|
||||
var environment = new Handlebars.Compiler().compile(ast, options);
|
||||
var templateSpec = new Handlebars.JavaScriptCompiler().compile(environment, options, undefined, true);
|
||||
return Handlebars.template(templateSpec);
|
||||
}
|
||||
|
||||
// Template is only compiled on first use and cached after that point.
|
||||
return function(context, options) {
|
||||
if (!compiled) {
|
||||
compiled = compile();
|
||||
}
|
||||
return compiled.call(this, context, options);
|
||||
};
|
||||
};
|
||||
|
||||
// END(BROWSER)
|
||||
|
||||
Reference in New Issue
Block a user