diff options
Diffstat (limited to 'lib/handlebars/compiler/javascript-compiler.js')
-rw-r--r-- | lib/handlebars/compiler/javascript-compiler.js | 7 |
1 files changed, 6 insertions, 1 deletions
diff --git a/lib/handlebars/compiler/javascript-compiler.js b/lib/handlebars/compiler/javascript-compiler.js index 22937f6..7ad400c 100644 --- a/lib/handlebars/compiler/javascript-compiler.js +++ b/lib/handlebars/compiler/javascript-compiler.js @@ -688,6 +688,7 @@ JavaScriptCompiler.prototype = { var prefix = '', inline = this.isInline(), stack, + createdStack, usedLiteral; // If we are currently inline then we want to merge the inline statement into the @@ -701,7 +702,8 @@ JavaScriptCompiler.prototype = { usedLiteral = true; } else { // Get or create the current stack name for use by the inline - var name = this.stackSlot ? this.topStackName() : this.incrStack(); + createdStack = !this.stackSlot; + var name = !createdStack ? this.topStackName() : this.incrStack(); prefix = '(' + this.push(name) + ' = ' + top + '),'; stack = this.topStack(); @@ -716,6 +718,9 @@ JavaScriptCompiler.prototype = { if (!usedLiteral) { this.popStack(); } + if (createdStack) { + this.stackSlot--; + } this.push('(' + prefix + item + ')'); } else { // Prevent modification of the context depth variable. Through replaceStack |