Make the function passed to a block helper have an identical signature to top-level template methods

This commit is contained in:
tomhuda
2011-02-14 16:05:01 -08:00
parent d7f93c09e7
commit 2b319bef2f
2 changed files with 37 additions and 3 deletions
+6 -3
View File
@@ -627,13 +627,16 @@ Handlebars.JavaScriptCompiler = function() {};
Handlebars.VM = {
programWithDepth: function(fn) {
var args = Array.prototype.slice.call(arguments, 1);
return function(context) {
return function(context, helpers, partials, data) {
args[0] = helpers || args[0];
args[1] = partials || args[1];
args[2] = data || args[2];
return fn.apply(this, [context].concat(args));
};
},
program: function(fn, helpers, partials, data) {
return function(context) {
return fn(context, helpers, partials, data);
return function(context, h2, p2, d2) {
return fn(context, h2 || helpers, p2 || partials, d2 || data);
};
},
noop: function() { return ""; },