diff options
author | kpdecker <kpdecker@gmail.com> | 2014-07-12 12:50:54 -0500 |
---|---|---|
committer | kpdecker <kpdecker@gmail.com> | 2014-07-12 12:50:54 -0500 |
commit | 271106d43fae96fc1287898568d000b871f19084 (patch) | |
tree | de4a23fe43b7e4d7cbec1830543b317751a03cfa /lib/handlebars/compiler/javascript-compiler.js | |
parent | 1fb7b51ee6bb8f4a2e395821a4648333a699a982 (diff) | |
download | handlebars.js-271106d43fae96fc1287898568d000b871f19084.zip handlebars.js-271106d43fae96fc1287898568d000b871f19084.tar.gz handlebars.js-271106d43fae96fc1287898568d000b871f19084.tar.bz2 |
Do not lookup pathed helpers on the helper stack
Fixes #764
Diffstat (limited to 'lib/handlebars/compiler/javascript-compiler.js')
-rw-r--r-- | lib/handlebars/compiler/javascript-compiler.js | 9 |
1 files changed, 4 insertions, 5 deletions
diff --git a/lib/handlebars/compiler/javascript-compiler.js b/lib/handlebars/compiler/javascript-compiler.js index 2d4b115..c4f3c27 100644 --- a/lib/handlebars/compiler/javascript-compiler.js +++ b/lib/handlebars/compiler/javascript-compiler.js @@ -369,7 +369,7 @@ JavaScriptCompiler.prototype = { return ' != null ? ' + lookup + ' : ' + current; } else { // Otherwise we can use generic falsy handling - return ' != null && ' + lookup; + return (falsy ? ' && ' : ' != null && ') + lookup; } }, true); } @@ -527,19 +527,18 @@ JavaScriptCompiler.prototype = { // and pushes the helper's return value onto the stack. // // If the helper is not found, `helperMissing` is called. - invokeHelper: function(paramSize, name, isRoot) { + invokeHelper: function(paramSize, name, isSimple, isRoot) { this.aliases.helperMissing = 'helpers.helperMissing'; - this.useRegister('helper'); var nonHelper = this.popStack(); var helper = this.setupHelper(paramSize, name); - var lookup = 'helper = ' + helper.name + ' || ' + nonHelper + ' || helperMissing'; + var lookup = (isSimple ? helper.name + ' || ' : '') + nonHelper + ' || helperMissing'; if (helper.paramsInit) { lookup += ',' + helper.paramsInit; } - this.push('(' + lookup + ',helper.call(' + helper.callParams + '))'); + this.push('((' + lookup + ').call(' + helper.callParams + '))'); // Always flush subexpressions. This is both to prevent the compounding size issue that // occurs when the code has to be duplicated for inlining and also to prevent errors |