summaryrefslogtreecommitdiffstats
path: root/lib/handlebars/compiler/javascript-compiler.js
diff options
context:
space:
mode:
Diffstat (limited to 'lib/handlebars/compiler/javascript-compiler.js')
-rw-r--r--lib/handlebars/compiler/javascript-compiler.js18
1 files changed, 9 insertions, 9 deletions
diff --git a/lib/handlebars/compiler/javascript-compiler.js b/lib/handlebars/compiler/javascript-compiler.js
index 7539068..cdf1693 100644
--- a/lib/handlebars/compiler/javascript-compiler.js
+++ b/lib/handlebars/compiler/javascript-compiler.js
@@ -220,7 +220,7 @@ JavaScriptCompiler.prototype = {
// On stack, after: return value of blockHelperMissing
//
// The purpose of this opcode is to take a block of the form
- // `{{#foo}}...{{/foo}}`, resolve the value of `foo`, and
+ // `{{#this.foo}}...{{/this.foo}}`, resolve the value of `foo`, and
// replace it on the stack with the result of properly
// invoking blockHelperMissing.
blockValue: function() {
@@ -244,8 +244,11 @@ JavaScriptCompiler.prototype = {
ambiguousBlockValue: function() {
this.context.aliases.blockHelperMissing = 'helpers.blockHelperMissing';
+ // We're being a bit cheeky and reusing the options value from the prior exec
var params = ["depth0"];
- this.setupParams(0, params);
+ this.setupParams(0, params, true);
+
+ this.flushInline();
var current = this.topStack();
params.splice(1, 0, current);
@@ -555,15 +558,12 @@ JavaScriptCompiler.prototype = {
var helper = this.setupHelper(0, name, helperCall);
var helperName = this.lastHelper = this.nameLookup('helpers', name, 'helper');
-
var nonHelper = this.nameLookup('depth' + this.lastContext, name, 'context');
- var nextStack = this.nextStack();
- if (helper.paramsInit) {
- this.pushSource(helper.paramsInit);
- }
- this.pushSource('if (helper = ' + helperName + ') { ' + nextStack + ' = helper.call(' + helper.callParams + '); }');
- this.pushSource('else { helper = ' + nonHelper + '; ' + nextStack + ' = typeof helper === functionType ? helper.call(' + helper.callParams + ') : helper; }');
+ this.push(
+ '((helper = ' + helperName + ' || ' + nonHelper
+ + (helper.paramsInit ? '),(' + helper.paramsInit : '') + '),'
+ + '(typeof helper === functionType ? helper.call(' + helper.callParams + ') : helper))');
},
// [invokePartial]