Inline foundHelper lookup

This commit is contained in:
kpdecker
2013-01-19 11:39:23 -06:00
parent 822d98a1ef
commit b1ea697b7d
+4 -4
View File
@@ -763,9 +763,9 @@ Handlebars.JavaScriptCompiler = function() {};
this.context.aliases.helperMissing = 'helpers.helperMissing';
var helper = this.lastHelper = this.setupHelper(paramSize, name);
this.register('foundHelper', helper.name);
this.useRegister('foundHelper');
this.pushStack("foundHelper ? foundHelper.call(" +
this.pushStack("(foundHelper = " + helper.name + ") ? foundHelper.call(" +
helper.callParams + ") " + ": helperMissing.call(" +
helper.helperMissingParams + ")");
},
@@ -801,12 +801,12 @@ Handlebars.JavaScriptCompiler = function() {};
var helper = this.setupHelper(0, name);
var helperName = this.lastHelper = this.nameLookup('helpers', name, 'helper');
this.register('foundHelper', helperName);
this.useRegister('foundHelper');
var nonHelper = this.nameLookup('depth' + this.lastContext, name, 'context');
var nextStack = this.nextStack();
this.source.push('if (foundHelper) { ' + nextStack + ' = foundHelper.call(' + helper.callParams + '); }');
this.source.push('if (foundHelper = ' + helperName + ') { ' + nextStack + ' = foundHelper.call(' + helper.callParams + '); }');
this.source.push('else { ' + nextStack + ' = ' + nonHelper + '; ' + nextStack + ' = typeof ' + nextStack + ' === functionType ? ' + nextStack + '.apply(depth0) : ' + nextStack + '; }');
},