Make sure options.hash is an empty {} if no hash is present to eliminate necessary guards in helpers
This commit is contained in:
@@ -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);
|
||||
},
|
||||
|
||||
Reference in New Issue
Block a user