Use x = a[y] || b[y] rather than if exists lookup

This commit is contained in:
kpdecker
2011-07-31 11:27:47 -05:00
parent c7e8ddd6b5
commit 2d538baf72
+6 -8
View File
@@ -476,17 +476,15 @@ Handlebars.JavaScriptCompiler = function() {};
if(name) {
var topStack = this.nextStack();
var lookupScoped = topStack + " = " + this.nameLookup('currentContext', name, 'context'),
toPush;
var toPush;
if (isScoped) {
toPush = lookupScoped;
toPush = topStack + " = " + this.nameLookup('currentContext', name, 'context');
} else {
toPush = "if('" + name + "' in helpers) { " + topStack +
" = " + this.nameLookup('helpers', name, 'helper') +
"; } else { " +
lookupScoped +
"; }";
toPush = topStack + " = "
+ this.nameLookup('helpers', name, 'helper')
+ " || "
+ this.nameLookup('currentContext', name, 'context');
}
this.source.push(toPush);