mirror of
https://github.com/meteor/meteor.git
synced 2026-05-02 03:01:46 -04:00
Start to fix dots in block helper args
This commit is contained in:
@@ -113,4 +113,84 @@ Tinytest.add("spacebars - compiler output", function (test) {
|
||||
};
|
||||
});
|
||||
|
||||
run("{{> foo bar}}",
|
||||
function() {
|
||||
var self = this;
|
||||
return function() {
|
||||
return Spacebars.include(Template["foo"] || self.lookup("foo"), {
|
||||
data: self.lookup("bar")
|
||||
});
|
||||
};
|
||||
});
|
||||
|
||||
run("{{> foo x=bar}}",
|
||||
function() {
|
||||
var self = this;
|
||||
return function() {
|
||||
return Spacebars.include(Template["foo"] || self.lookup("foo"), {
|
||||
x: self.lookup("bar")
|
||||
});
|
||||
};
|
||||
});
|
||||
|
||||
run("{{> foo bar.baz}}",
|
||||
function() {
|
||||
var self = this;
|
||||
return function() {
|
||||
return Spacebars.include(Template["foo"] || self.lookup("foo"), {
|
||||
data: function() {
|
||||
return Spacebars.dot(self.lookup("bar"), "baz");
|
||||
}
|
||||
});
|
||||
};
|
||||
});
|
||||
|
||||
run("{{> foo x=bar.baz}}",
|
||||
function() {
|
||||
var self = this;
|
||||
return function() {
|
||||
return Spacebars.include(Template["foo"] || self.lookup("foo"), {
|
||||
x: function() {
|
||||
return Spacebars.dot(self.lookup("bar"), "baz");
|
||||
}
|
||||
});
|
||||
};
|
||||
});
|
||||
|
||||
run("{{> foo bar baz}}",
|
||||
{fail: 'Only one positional argument'});
|
||||
|
||||
run("{{#foo bar baz}}aaa{{/foo}}",
|
||||
function() {
|
||||
var self = this;
|
||||
return function() {
|
||||
return Spacebars.include(Template["foo"] || self.lookup("foo"), {
|
||||
__content: UI.block(function() {
|
||||
var self = this;
|
||||
return "aaa";
|
||||
}),
|
||||
data: function() {
|
||||
return Spacebars.call2(self.lookup("bar"), self.lookup("baz"));
|
||||
}
|
||||
});
|
||||
};
|
||||
});
|
||||
|
||||
run("{{#foo p.q r.s}}aaa{{/foo}}",
|
||||
function() {
|
||||
var self = this;
|
||||
return function() {
|
||||
return Spacebars.include(Template["foo"] || self.lookup("foo"), {
|
||||
__content: UI.block(function() {
|
||||
var self = this;
|
||||
return "aaa";
|
||||
}),
|
||||
data: function() {
|
||||
return Spacebars.call2(
|
||||
Spacebars.dot(self.lookup("p"), "q"),
|
||||
Spacebars.dot(self.lookup("r"), "s"));
|
||||
}
|
||||
});
|
||||
};
|
||||
});
|
||||
});
|
||||
|
||||
@@ -1465,6 +1465,13 @@ var codeGenInclusionArgs = function (tag) {
|
||||
'UI.block(' + Spacebars.compile2(tag.elseContent) + ')');
|
||||
}
|
||||
|
||||
// precalculate the number of positional args
|
||||
var numPosArgs = 0;
|
||||
_.each(tag.args, function (arg) {
|
||||
if (arg.length === 2)
|
||||
numPosArgs++;
|
||||
});
|
||||
|
||||
_.each(tag.args, function (arg) {
|
||||
var argType = arg[0];
|
||||
var argValue = arg[1];
|
||||
@@ -1487,11 +1494,8 @@ var codeGenInclusionArgs = function (tag) {
|
||||
// while `Spacebars.dot(self.lookup("foo"), "bar")` may establish
|
||||
// dependencies.
|
||||
//
|
||||
// In the multi-positional-arg construct, no point wrapping
|
||||
// pos args after the first in a closure, as we have to
|
||||
// rerun the whole thing anyway if one changes.
|
||||
if (! ((path.length === 1) ||
|
||||
((! isKeyword) && posArgs.length)))
|
||||
// In the multi-positional-arg construct, don't wrap pos args.
|
||||
if (! ((path.length === 1) || (numPosArgs > 1)))
|
||||
argCode = 'function () { return ' + argCode + '; }';
|
||||
break;
|
||||
default:
|
||||
|
||||
Reference in New Issue
Block a user