diff options
author | Kevin Decker <kpdecker@gmail.com> | 2013-04-07 17:21:40 -0700 |
---|---|---|
committer | Kevin Decker <kpdecker@gmail.com> | 2013-04-07 17:21:40 -0700 |
commit | 075fdb8ac4b77520bebf321bf51636d2f4212841 (patch) | |
tree | 083687054dd0571983216492aea5ca76dda6624c /lib/handlebars/compiler/compiler.js | |
parent | 4429ffa9f37620afb211d15480545bd12b54bba5 (diff) | |
parent | 53de75927ce3ff622901ae00b39c5e677fb6ba25 (diff) | |
download | handlebars.js-075fdb8ac4b77520bebf321bf51636d2f4212841.zip handlebars.js-075fdb8ac4b77520bebf321bf51636d2f4212841.tar.gz handlebars.js-075fdb8ac4b77520bebf321bf51636d2f4212841.tar.bz2 |
Merge pull request #454 from leshill/fix_string_mode_contexts
Add contexts for string mode hash values
Diffstat (limited to 'lib/handlebars/compiler/compiler.js')
-rw-r--r-- | lib/handlebars/compiler/compiler.js | 15 |
1 files changed, 13 insertions, 2 deletions
diff --git a/lib/handlebars/compiler/compiler.js b/lib/handlebars/compiler/compiler.js index 7c8b552..98f5396 100644 --- a/lib/handlebars/compiler/compiler.js +++ b/lib/handlebars/compiler/compiler.js @@ -189,6 +189,10 @@ Compiler.prototype = { val = pair[1]; if (this.options.stringParams) { + if(val.depth) { + this.addDepth(val.depth); + } + this.opcode('getContext', val.depth || 0); this.opcode('pushStringParam', val.stringModeValue, val.type); } else { this.accept(val); @@ -773,16 +777,18 @@ JavaScriptCompiler.prototype = { if (this.options.stringParams) { this.register('hashTypes', '{}'); + this.register('hashContexts', '{}'); } }, pushHash: function() { - this.hash = {values: [], types: []}; + this.hash = {values: [], types: [], contexts: []}; }, popHash: function() { var hash = this.hash; this.hash = undefined; if (this.options.stringParams) { + this.register('hashContexts', '{' + hash.contexts.join(',') + '}'); this.register('hashTypes', '{' + hash.types.join(',') + '}'); } this.push('{\n ' + hash.values.join(',\n ') + '\n }'); @@ -925,14 +931,18 @@ JavaScriptCompiler.prototype = { // and pushes the hash back onto the stack. assignToHash: function(key) { var value = this.popStack(), + context, type; if (this.options.stringParams) { type = this.popStack(); - this.popStack(); + context = this.popStack(); } var hash = this.hash; + if (context) { + hash.contexts.push("'" + key + "': " + context); + } if (type) { hash.types.push("'" + key + "': " + type); } @@ -1183,6 +1193,7 @@ JavaScriptCompiler.prototype = { if (this.options.stringParams) { options.push("contexts:[" + contexts.join(",") + "]"); options.push("types:[" + types.join(",") + "]"); + options.push("hashContexts:hashContexts"); options.push("hashTypes:hashTypes"); } |