mirror of
https://github.com/discourse/discourse.git
synced 2025-05-22 20:41:24 +08:00
DEV: Upgrade our widget handlebars compiler
Now supports subexpressions such as i18n and concat, plus automatic attaching of widgets similar to ember.
This commit is contained in:
@ -204,6 +204,45 @@ widgetTest("widget attaching", {
|
||||
}
|
||||
});
|
||||
|
||||
widgetTest("magic attaching by name", {
|
||||
template: `{{mount-widget widget="attach-test"}}`,
|
||||
|
||||
beforeEach() {
|
||||
createWidget("test-embedded", { tagName: "div.embedded" });
|
||||
|
||||
createWidget("attach-test", {
|
||||
tagName: "div.container",
|
||||
template: hbs`{{test-embedded attrs=attrs}}`
|
||||
});
|
||||
},
|
||||
|
||||
test(assert) {
|
||||
assert.ok(find(".container").length, "renders container");
|
||||
assert.ok(find(".container .embedded").length, "renders attached");
|
||||
}
|
||||
});
|
||||
|
||||
widgetTest("custom attrs to a magic attached widget", {
|
||||
template: `{{mount-widget widget="attach-test"}}`,
|
||||
|
||||
beforeEach() {
|
||||
createWidget("testing", {
|
||||
tagName: "span.value",
|
||||
template: hbs`{{attrs.value}}`
|
||||
});
|
||||
|
||||
createWidget("attach-test", {
|
||||
tagName: "div.container",
|
||||
template: hbs`{{testing value=(concat "hello" " " "world")}}`
|
||||
});
|
||||
},
|
||||
|
||||
test(assert) {
|
||||
assert.ok(find(".container").length, "renders container");
|
||||
assert.equal(find(".container .value").text(), "hello world");
|
||||
}
|
||||
});
|
||||
|
||||
widgetTest("handlebars d-icon", {
|
||||
template: `{{mount-widget widget="hbs-icon-test" args=args}}`,
|
||||
|
||||
|
Reference in New Issue
Block a user