diff options
author | tomhuda <tomhuda@strobecorp.com> | 2011-08-02 16:32:57 -0700 |
---|---|---|
committer | tomhuda <tomhuda@strobecorp.com> | 2011-08-02 16:32:57 -0700 |
commit | 2f7b724d5a2313bec70e8155c6165e23305dc3b1 (patch) | |
tree | f3794eb3ca537191a3f062896c7326b8e4fcbf61 /lib/handlebars/compiler/compiler.js | |
parent | 318c08a97e6f8cce99be04f7fe04b8c6e790e7ae (diff) | |
download | handlebars.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.js | 11 |
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); }, |