mirror of
https://github.com/meteor/meteor.git
synced 2026-05-02 03:01:46 -04:00
ignore extra block helper args as intended
This commit is contained in:
@@ -224,10 +224,12 @@ Handlebars.evaluate = function (ast, data, options) {
|
||||
if (isNested && values.length > 1) {
|
||||
// at least one positional argument; not no args
|
||||
// or only hash args.
|
||||
if (typeof values[1] === "function")
|
||||
var oneArg = values[1];
|
||||
if (typeof oneArg === "function")
|
||||
// invoke the positional arguments
|
||||
// (and hash arguments) as a nested helper invocation.
|
||||
values = [values[0], apply(values.slice(1), {hash:hash})];
|
||||
oneArg = apply(values.slice(1), {hash:hash});
|
||||
values = [values[0], oneArg];
|
||||
// keyword args don't go to the block helper, then.
|
||||
extra.hash = {};
|
||||
} else {
|
||||
|
||||
@@ -181,4 +181,5 @@
|
||||
(nokeys={{#arg_and_dict "foo" x="foo"}}{{/arg_and_dict}})
|
||||
(nokeys={{#arg_and_dict tree x="foo"}}{{/arg_and_dict}})
|
||||
(biggie={{#get_arg helperListFour platypus thisTest fancyhelper.currentFruit fancyhelper.currentCountry.unicorns a=platypus b=thisTest c=fancyhelper.currentFruit d=fancyhelper.currentCountry.unicorns}}{{/get_arg}})
|
||||
(twoArgBlock={{#two_args "foo" "foo"}}{{/two_args}})
|
||||
</template>
|
||||
|
||||
@@ -292,6 +292,10 @@ Tinytest.add("templating - helpers and dots", function(test) {
|
||||
Template.test_helpers_i.get_arg = function(arg) {
|
||||
return arg;
|
||||
};
|
||||
Template.test_helpers_i.two_args = function(arg1, arg2) {
|
||||
return [typeof arg1 === "string",
|
||||
typeof arg2 === "string"].join();
|
||||
};
|
||||
Template.test_helpers_i.helperListFour = listFour;
|
||||
|
||||
trials =
|
||||
@@ -305,5 +309,7 @@ Tinytest.add("templating - helpers and dots", function(test) {
|
||||
test.equal(trials[3], "(nokeys=0)");
|
||||
test.equal(trials[4],
|
||||
'(biggie=eggs leaf guava 0 a:eggs b:leaf c:guava d:0)');
|
||||
test.equal(trials.length, 5);
|
||||
// can't pass > 1 positional arg to block helper
|
||||
test.equal(trials[5], "(twoArgBlock=true,false)");
|
||||
test.equal(trials.length, 6);
|
||||
});
|
||||
|
||||
Reference in New Issue
Block a user