Make sure options.hash is an empty {} if no hash is present to eliminate necessary guards in helpers

This commit is contained in:
tomhuda
2011-08-02 16:32:57 -07:00
parent 318c08a97e
commit 2f7b724d5a
+7 -4
View File
@@ -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);
},