diff options
author | Kevin Decker <kpdecker@gmail.com> | 2014-03-05 14:38:26 -0600 |
---|---|---|
committer | Kevin Decker <kpdecker@gmail.com> | 2014-03-05 14:38:26 -0600 |
commit | 7dd64e5e92bb189052f5ecbd959e6a26cc294ed5 (patch) | |
tree | 9a3899c5e8a6218aeeb6dae62d800dde1d44988e /lib | |
parent | 674d07fd033498057defeb14adeade8f9868d1f8 (diff) | |
parent | 8493822b621470a7423ec05d9f09e717725e3943 (diff) | |
download | handlebars.js-7dd64e5e92bb189052f5ecbd959e6a26cc294ed5.zip handlebars.js-7dd64e5e92bb189052f5ecbd959e6a26cc294ed5.tar.gz handlebars.js-7dd64e5e92bb189052f5ecbd959e6a26cc294ed5.tar.bz2 |
Merge pull request #749 from jenseng/option_subexpressions_fix
properly handle multiple subexpressions in the same hash, fixes #748
Diffstat (limited to 'lib')
-rw-r--r-- | lib/handlebars/compiler/compiler.js | 12 | ||||
-rw-r--r-- | lib/handlebars/compiler/javascript-compiler.js | 7 |
2 files changed, 9 insertions, 10 deletions
diff --git a/lib/handlebars/compiler/compiler.js b/lib/handlebars/compiler/compiler.js index 7acff1f..99d6f4f 100644 --- a/lib/handlebars/compiler/compiler.js +++ b/lib/handlebars/compiler/compiler.js @@ -188,15 +188,15 @@ Compiler.prototype = { }, hash: function(hash) { - var pairs = hash.pairs, pair; + var pairs = hash.pairs, i, l; this.opcode('pushHash'); - for(var i=0, l=pairs.length; i<l; i++) { - pair = pairs[i]; - - this.pushParam(pair[1]); - this.opcode('assignToHash', pair[0]); + for(i=0, l=pairs.length; i<l; i++) { + this.pushParam(pairs[i][1]); + } + while(i--) { + this.opcode('assignToHash', pairs[i][0]); } this.opcode('popHash'); }, diff --git a/lib/handlebars/compiler/javascript-compiler.js b/lib/handlebars/compiler/javascript-compiler.js index 1125e61..514dfcc 100644 --- a/lib/handlebars/compiler/javascript-compiler.js +++ b/lib/handlebars/compiler/javascript-compiler.js @@ -608,11 +608,10 @@ JavaScriptCompiler.prototype = { // [assignToHash] // - // On stack, before: value, hash, ... - // On stack, after: hash, ... + // On stack, before: value, ..., hash, ... + // On stack, after: ..., hash, ... // - // Pops a value and hash off the stack, assigns `hash[key] = value` - // and pushes the hash back onto the stack. + // Pops a value off the stack and assigns it to the current hash assignToHash: function(key) { var value = this.popStack(), context, |