summaryrefslogtreecommitdiffstats
path: root/lib/handlebars/compiler/compiler.js
diff options
context:
space:
mode:
authortomhuda <tomhuda@tilde.io>2012-05-28 19:06:08 -0700
committertomhuda <tomhuda@tilde.io>2012-05-28 19:06:08 -0700
commit1082ec2414e7d9c0cd5dcafa0dfa5510e3b1ed60 (patch)
tree968e2eaf5095f06de4160aabebfae7cbad44edc6 /lib/handlebars/compiler/compiler.js
parent727eb26cb6a9e89ab08596dedbabcec0becb4d75 (diff)
downloadhandlebars.js-1082ec2414e7d9c0cd5dcafa0dfa5510e3b1ed60.zip
handlebars.js-1082ec2414e7d9c0cd5dcafa0dfa5510e3b1ed60.tar.gz
handlebars.js-1082ec2414e7d9c0cd5dcafa0dfa5510e3b1ed60.tar.bz2
Fix a bug where registers were shared
Diffstat (limited to 'lib/handlebars/compiler/compiler.js')
-rw-r--r--lib/handlebars/compiler/compiler.js15
1 files changed, 6 insertions, 9 deletions
diff --git a/lib/handlebars/compiler/compiler.js b/lib/handlebars/compiler/compiler.js
index cab5b30..20a558d 100644
--- a/lib/handlebars/compiler/compiler.js
+++ b/lib/handlebars/compiler/compiler.js
@@ -393,14 +393,14 @@ Handlebars.JavaScriptCompiler = function() {};
this.isChild = !!context;
this.context = context || {
programs: [],
- aliases: { },
- registers: {list: []}
+ aliases: { }
};
this.preamble();
this.stackSlot = 0;
this.stackVars = [];
+ this.registers = { list: [] };
this.compileStack = [];
this.compileChildren(environment, options);
@@ -456,10 +456,7 @@ Handlebars.JavaScriptCompiler = function() {};
},
createFunctionContext: function(asObject) {
- var locals = this.stackVars;
- if (!this.isChild) {
- locals = locals.concat(this.context.registers.list);
- }
+ var locals = this.stackVars.concat(this.registers.list);
if(locals.length > 0) {
this.source[1] = this.source[1] + ", " + locals.join(", ");
@@ -854,9 +851,9 @@ Handlebars.JavaScriptCompiler = function() {};
},
useRegister: function(name) {
- if(!this.context.registers[name]) {
- this.context.registers[name] = true;
- this.context.registers.list.push(name);
+ if(!this.registers[name]) {
+ this.registers[name] = true;
+ this.registers.list.push(name);
}
},