summaryrefslogtreecommitdiffstats
path: root/lib/handlebars/compiler/compiler.js
diff options
context:
space:
mode:
authorkpdecker <kpdecker@gmail.com>2011-07-31 11:27:47 -0500
committerkpdecker <kpdecker@gmail.com>2011-07-31 11:27:47 -0500
commit2d538baf726f2b2da0c8e35956416e2946c88997 (patch)
tree575f6d0c4ded0b0f64726066aca5a7f65236a2c0 /lib/handlebars/compiler/compiler.js
parentc7e8ddd6b572e3b26c93708c7ff0fd1e08261054 (diff)
downloadhandlebars.js-2d538baf726f2b2da0c8e35956416e2946c88997.zip
handlebars.js-2d538baf726f2b2da0c8e35956416e2946c88997.tar.gz
handlebars.js-2d538baf726f2b2da0c8e35956416e2946c88997.tar.bz2
Use x = a[y] || b[y] rather than if exists lookup
Diffstat (limited to 'lib/handlebars/compiler/compiler.js')
-rw-r--r--lib/handlebars/compiler/compiler.js14
1 files changed, 6 insertions, 8 deletions
diff --git a/lib/handlebars/compiler/compiler.js b/lib/handlebars/compiler/compiler.js
index d7ff3a7..613fbd3 100644
--- a/lib/handlebars/compiler/compiler.js
+++ b/lib/handlebars/compiler/compiler.js
@@ -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);