A platform for community discussion. Free, open, simple.
DEV: Allow `transformed` values to be used in all widget hbs statements (#13331)
David Taylor9811a1c5d9bc
diff --git a/app/assets/javascripts/discourse/tests/integration/widgets/widget-test.js b/app/assets/javascripts/discourse/tests/integration/widgets/widget-test.jsindex 6df1ef695a8..aa1a27b0164 100644--- a/app/assets/javascripts/discourse/tests/integration/widgets/widget-test.js+++ b/app/assets/javascripts/discourse/tests/integration/widgets/widget-test.js@@ -262,6 +262,30 @@ discourseModule("Integration | Component | Widget | base", function (hooks) {},});+ componentTest("using transformed values in a subexpression", {+ template: hbs`{{mount-widget widget="attach-test"}}`,++ beforeEach() {+ createWidget("testing", {+ tagName: "span.value",+ template: widgetHbs`{{attrs.value}}`,+ });++ createWidget("attach-test", {+ transform() {+ return { someValue: "world" };+ },+ tagName: "div.container",+ template: widgetHbs`{{testing value=(concat "hello" " " transformed.someValue)}}`,+ });+ },++ test(assert) {+ assert.ok(queryAll(".container").length, "renders container");+ assert.equal(queryAll(".container .value").text(), "hello world");+ },+ });+componentTest("handlebars d-icon", {template: hbs`{{mount-widget widget="hbs-icon-test" args=args}}`,diff --git a/lib/javascripts/widget-hbs-compiler.js b/lib/javascripts/widget-hbs-compiler.jsindex e36aa3549c5..63b12cdc72f 100644--- a/lib/javascripts/widget-hbs-compiler.js+++ b/lib/javascripts/widget-hbs-compiler.js@@ -16,7 +16,7 @@ function sexpValue(value) {} else if (value.type === "SubExpression") {return sexp(value);}- return pValue;+ return resolve(pValue);}function pairsToObj(pairs) {