Update specs and code so that the function passed to block helpers has the same API as regular compiled templates
This commit is contained in:
@@ -3,7 +3,7 @@ var handlebars = require("handlebars/parser").parser;
|
||||
// BEGIN(BROWSER)
|
||||
var Handlebars = {};
|
||||
|
||||
Handlebars.VERSION = "1.0.beta.1";
|
||||
Handlebars.VERSION = "1.0.beta.2";
|
||||
|
||||
Handlebars.Parser = handlebars;
|
||||
|
||||
|
||||
@@ -695,22 +695,30 @@ Handlebars.JavaScriptCompiler = function() {};
|
||||
})(Handlebars.Compiler, Handlebars.JavaScriptCompiler);
|
||||
|
||||
Handlebars.VM = {
|
||||
programWithDepth: function(fn, passedHelpers, passedPartials, passedData, $depth) {
|
||||
programWithDepth: function(fn, helpers, partials, data, $depth) {
|
||||
var args = Array.prototype.slice.call(arguments, 4);
|
||||
|
||||
return function(context, helpers, partials, data) {
|
||||
var options = {
|
||||
helpers: helpers || passedHelpers,
|
||||
partials: partials || passedPartials,
|
||||
data: data || passedData
|
||||
return function(context, options) {
|
||||
options = options || {};
|
||||
|
||||
options = {
|
||||
helpers: options.helpers || helpers,
|
||||
partials: options.partials || partials,
|
||||
data: options.data || data
|
||||
};
|
||||
|
||||
return fn.apply(this, [context, options].concat(args));
|
||||
};
|
||||
},
|
||||
program: function(fn, helpers, partials, data) {
|
||||
return function(context, h2, p2, d2) {
|
||||
return fn(context, {helpers: h2 || helpers, partials: p2 || partials, data: d2 || data});
|
||||
return function(context, options) {
|
||||
options = options || {};
|
||||
|
||||
return fn(context, {
|
||||
helpers: options.helpers || helpers,
|
||||
partials: options.partials || partials,
|
||||
data: options.data || data
|
||||
});
|
||||
};
|
||||
},
|
||||
noop: function() { return ""; },
|
||||
|
||||
+2
-2
@@ -608,7 +608,7 @@ test("you can override inherited data when invoking a helper", function() {
|
||||
|
||||
var helpers = {
|
||||
hello: function(fn) {
|
||||
return fn({exclaim: "?", zomg: "world"}, null, null, {adjective: "sad"});
|
||||
return fn({exclaim: "?", zomg: "world"}, { data: {adjective: "sad"} });
|
||||
},
|
||||
world: function(thing, options) {
|
||||
return options.data.adjective + " " + thing + (this.exclaim || "");
|
||||
@@ -625,7 +625,7 @@ test("you can override inherited data when invoking a helper with depth", functi
|
||||
|
||||
var helpers = {
|
||||
hello: function(fn) {
|
||||
return fn({exclaim: "?"}, null, null, {adjective: "sad"});
|
||||
return fn({exclaim: "?"}, { data: {adjective: "sad"} });
|
||||
},
|
||||
world: function(thing, options) {
|
||||
return options.data.adjective + " " + thing + (this.exclaim || "");
|
||||
|
||||
Reference in New Issue
Block a user