diff --git a/text/0000-dynamic-tag-names.md b/text/0000-dynamic-tag-names.md index fef8b31fab..744ef61d1d 100644 --- a/text/0000-dynamic-tag-names.md +++ b/text/0000-dynamic-tag-names.md @@ -45,9 +45,21 @@ For instance: The glimmer parser needs to be able to distinguish this from any other interpolation in the so called _element space_, like the future [Element Modifiers](https://github.com/emberjs/rfcs/pull/353). -This syntax presents two edge cases that we need clarification: +This syntax presents some edge cases that we need clarification: -1 - What happens when the value in the interpolated in the opening and closing tags are different? +#### Should we allow helpers inside those interpolations? + +For instance: + +```hbs +<{{or @tagName "div"}}> + + +``` + +I think that this repetition is ugly but people will need it and we must allow it. + +#### What happens when the value in the interpolated in the opening and closing tags are different? ```hbs <{{@tagName}} class="pt-10 pb-10 ps-20 box-shadow" ...attributes> @@ -55,9 +67,10 @@ This syntax presents two edge cases that we need clarification: ``` -This is clearly illegal and must throw an exception in development or production alike. +This is clearly illegal and must throw an exception in build time. +This also applies to interpolated subexpressions. They must not only be equivalent but **the exact same expression**. -2 - What if the interpolated value is not a string? (`null`, `undefined` or a number/object). +#### What if the interpolated value is not a string? (`null`, `undefined` or a number/object). Any value other than a String must throw an exception in development or production alike. @@ -67,7 +80,7 @@ For those not familiar with `<>` in React, that is used to generate DOM fragm element. I lean towards considering that a runtime error, but I could be convinced otherwise. -3 - Should the tag name be _unbound_? +#### Should the tag name be _unbound_? The tag name of a DOM element is not something that can be changed in runtime. Changing it once set would mean removing the old element and creating a new one, copying the content from one element to the new one. @@ -99,23 +112,4 @@ We can propose other alternative syntax. For instance, we could have a special b ## Unresolved questions -#### Should we allow helpers inside those interpolations? - -For instance: -```hbs -<{{or @tagName "div"}}> - - -``` - -I think that this repetition makes templates harder to read, so I advocate that only simple bindings -can be passed in. If the user wants to use something more complex than a binding, they could use the `let`/`with` helpers -for that. - -```hbs -{{#with (or @tagName "div") as |tagName|}} - <{{tagName}} class="foo"> - ... - -{{/with}} -``` +--- \ No newline at end of file