Got handleExpression written up.

This commit is contained in:
Alan Johnson
2010-09-14 20:37:03 -04:00
parent 384ebf6373
commit 00abfd3164
+18 -6
View File
@@ -166,17 +166,28 @@ var Handlebars = {
}
},
handleBlock: function(lookup, context, proxy, fn, notFn) {
handleBlock: function(lookup, context, arg, fn, notFn) {
var out = "";
if (Handlebars.isFunction(lookup)) {
out = out + lookup.call(context, proxy, fn);
out = out + lookup.call(context, arg, fn);
}
else if (typeof lookup != 'undefined') {
out = out + Handlebars.helperMissing.call(proxy, lookup, fn);
out = out + Handlebars.helperMissing.call(arg, lookup, fn);
}
if (notFn != null && Handlebars.isFunction(lookup.not)) {
out = out + lookup.not.call(context, proxy, notFn);
out = out + lookup.not.call(context, arg, notFn);
}
return out;
},
handleExpression: function(lookup, context, arg, isEscaped) {
var out = "";
if (Handlebars.isFunction(lookup)) {
out = out + Handlebars.filterOutput(lookup.call(context, arg), isEscaped);
} else if(!Handlebars.isEmpty(lookup)) {
out = out + Handlebars.filterOutput(lookup, isEscaped);
}
return out;
@@ -282,9 +293,10 @@ Handlebars.Compiler.prototype = {
},
addExpression: function(mustache, param) {
param = param || null;
var expr = this.lookupFor(mustache);
this.fn += "if (Handlebars.isFunction(" + expr + ")) out = out + Handlebars.filterOutput(" + expr + ".call(Handlebars.buildContext(context, stack), " + param + "), " + this.escaped + "); ";
this.fn += "else if(typeof " + expr + "!== 'undefined') out = out + Handlebars.filterOutput(" + expr + ", " + this.escaped + "); ";
this.fn += "var proxy = Handlebars.buildContext(context, stack);"
this.fn += "out = out + Handlebars.handleExpression(" + expr + ", proxy, " + param + ", " + this.escaped + ");";
},
addInvertedSection: function(mustache) {