From c54cadcf8f2a13607888fd78fc5505caceb4bdd2 Mon Sep 17 00:00:00 2001 From: Alan Johnson Date: Fri, 5 Nov 2010 15:57:59 -0400 Subject: [PATCH] Fixed strange stack issue. --- lib/handlebars.js | 7 ++++--- 1 file changed, 4 insertions(+), 3 deletions(-) diff --git a/lib/handlebars.js b/lib/handlebars.js index f064449e..f6a929f3 100644 --- a/lib/handlebars.js +++ b/lib/handlebars.js @@ -393,10 +393,11 @@ Handlebars.Compiler.prototype = { // don't need to be globally unique, just per compiler var fnId = "fn" + this.pointer.toString(); this.fn += "var wrappedContext = Handlebars.buildContext(context, stack);"; - this.fn += "stack.push(context);"; this.fn += "var " + fnId + " = function(context) {" + result + "}; "; this.fn += "lookup = " + this.lookupFor(mustache) + "; "; - + this.fn += "arg = " + param + ";"; + this.fn += "stack.push(context);"; + if (compiler.continueInverted) { var invertedCompiler = this.compileToEndOfBlock(mustache); this.fn += " var " + fnId + "Not = function(context) { " + invertedCompiler.fn + " };"; @@ -404,7 +405,7 @@ Handlebars.Compiler.prototype = { else { this.fn += " var " + fnId + "Not = null;"; } - this.fn += "out = out + Handlebars.handleBlock(lookup, wrappedContext, " + param + ", " + fnId + ", " + fnId + "Not);" + this.fn += "out = out + Handlebars.handleBlock(lookup, wrappedContext, arg, " + fnId + ", " + fnId + "Not);" this.fn += "stack.pop();"; this.openBlock = false;