Skip to content

Commit

Permalink
Use ID lookup for ambiguous helper evaluation
Browse files Browse the repository at this point in the history
Final change for #731
  • Loading branch information
kpdecker committed Jul 7, 2014
1 parent 107aa4a commit c90cfe2
Show file tree
Hide file tree
Showing 2 changed files with 4 additions and 1 deletion.
2 changes: 2 additions & 0 deletions lib/handlebars/compiler/compiler.js
Original file line number Diff line number Diff line change
Expand Up @@ -245,6 +245,8 @@ Compiler.prototype = {
this.opcode('pushProgram', program);
this.opcode('pushProgram', inverse);

this.ID(id);

this.opcode('invokeAmbiguous', name, isBlock);
},

Expand Down
3 changes: 2 additions & 1 deletion lib/handlebars/compiler/javascript-compiler.js
Original file line number Diff line number Diff line change
Expand Up @@ -577,11 +577,12 @@ JavaScriptCompiler.prototype = {
this.aliases.functionType = '"function"';
this.useRegister('helper');

var nonHelper = this.popStack();

this.emptyHash();
var helper = this.setupHelper(0, name, helperCall);

var helperName = this.lastHelper = this.nameLookup('helpers', name, 'helper');
var nonHelper = '(depth' + this.lastContext + ' && ' + this.nameLookup('depth' + this.lastContext, name, 'context') + ')';

this.push(
'((helper = ' + helperName + ' || ' + nonHelper
Expand Down

0 comments on commit c90cfe2

Please sign in to comment.