Bind functions to the context properly.

The regression was introduced in 1.0.rc.1.

This fixes issue #317.
This commit is contained in:
Tyson Tate
2012-09-19 16:03:46 -07:00
parent b5074a88ec
commit 42120d1177
2 changed files with 14 additions and 2 deletions
+2 -2
View File
@@ -642,7 +642,7 @@ Handlebars.JavaScriptCompiler = function() {};
this.context.aliases.functionType = '"function"';
this.replaceStack(function(current) {
return "typeof " + current + " === functionType ? " + current + "() : " + current;
return "typeof " + current + " === functionType ? " + current + ".apply(depth0) : " + current;
});
},
@@ -787,7 +787,7 @@ Handlebars.JavaScriptCompiler = function() {};
var nextStack = this.nextStack();
this.source.push('if (foundHelper) { ' + nextStack + ' = foundHelper.call(' + helper.callParams + '); }');
this.source.push('else { ' + nextStack + ' = ' + nonHelper + '; ' + nextStack + ' = typeof ' + nextStack + ' === functionType ? ' + nextStack + '() : ' + nextStack + '; }');
this.source.push('else { ' + nextStack + ' = ' + nonHelper + '; ' + nextStack + ' = typeof ' + nextStack + ' === functionType ? ' + nextStack + '.apply(depth0) : ' + nextStack + '; }');
},
// [invokePartial]