Added support for expressions that reference functions.
This commit is contained in:
+3
-1
@@ -2,6 +2,7 @@ Handlebars = {
|
||||
compile: function(string) {
|
||||
var compiler = new Handlebars.Compiler(string);
|
||||
var result = compiler.compile();
|
||||
console.log(result);
|
||||
return new Function("context", "fallback", "fallback = fallback || {}; var stack = [];" + result);
|
||||
},
|
||||
|
||||
@@ -118,7 +119,8 @@ Handlebars.Compiler.prototype = {
|
||||
},
|
||||
|
||||
addExpression: function(mustache) {
|
||||
this.fn += "out = out + " + this.lookupFor(mustache) + "; ";
|
||||
var expr = this.lookupFor(mustache);
|
||||
this.fn += "out = out + (Handlebars.isFunction(" + expr + ") ? " + expr + "() : " + expr + "); ";
|
||||
},
|
||||
|
||||
lookupFor: function(param) {
|
||||
|
||||
Reference in New Issue
Block a user