summaryrefslogtreecommitdiffstats
path: root/lib/handlebars/compiler/compiler.js
diff options
context:
space:
mode:
authortomhuda <tomhuda@strobecorp.com>2011-08-02 16:32:57 -0700
committertomhuda <tomhuda@strobecorp.com>2011-08-02 16:32:57 -0700
commit2f7b724d5a2313bec70e8155c6165e23305dc3b1 (patch)
treef3794eb3ca537191a3f062896c7326b8e4fcbf61 /lib/handlebars/compiler/compiler.js
parent318c08a97e6f8cce99be04f7fe04b8c6e790e7ae (diff)
downloadhandlebars.js-2f7b724d5a2313bec70e8155c6165e23305dc3b1.zip
handlebars.js-2f7b724d5a2313bec70e8155c6165e23305dc3b1.tar.gz
handlebars.js-2f7b724d5a2313bec70e8155c6165e23305dc3b1.tar.bz2
Make sure options.hash is an empty {} if no hash is present to eliminate necessary guards in helpers
Diffstat (limited to 'lib/handlebars/compiler/compiler.js')
-rw-r--r--lib/handlebars/compiler/compiler.js11
1 files changed, 7 insertions, 4 deletions
diff --git a/lib/handlebars/compiler/compiler.js b/lib/handlebars/compiler/compiler.js
index 5f4dca6..b0647da 100644
--- a/lib/handlebars/compiler/compiler.js
+++ b/lib/handlebars/compiler/compiler.js
@@ -574,14 +574,17 @@ Handlebars.JavaScriptCompiler = function() {};
populateParams: function(paramSize, helperId, program, inverse, hasHash, fn) {
var needsRegister = hasHash || this.options.stringParams || inverse || this.options.data;
var id = this.popStack(), nextStack;
- var params = [], param, stringParam;
+ var params = [], param, stringParam, stringOptions;
if (needsRegister) {
this.register('tmp1', program);
+ stringOptions = 'tmp1';
+ } else {
+ stringOptions = '{ hash: {} }';
}
- if (hasHash) {
- var hash = this.popStack();
+ if (needsRegister) {
+ var hash = (hasHash ? this.popStack() : '{}');
this.source.push('tmp1.hash = ' + hash + ';');
}
@@ -607,7 +610,7 @@ Handlebars.JavaScriptCompiler = function() {};
this.source.push('tmp1.data = data;');
}
- params.push(needsRegister ? 'tmp1' : '{}');
+ params.push(stringOptions);
this.populateCall(params, id, helperId || id, fn);
},