Skip to content

Commit

Permalink
More feedback
Browse files Browse the repository at this point in the history
  • Loading branch information
cibernox committed Oct 14, 2018
1 parent 6a13a5a commit a3b5824
Showing 1 changed file with 19 additions and 25 deletions.
44 changes: 19 additions & 25 deletions text/0000-dynamic-tag-names.md
Original file line number Diff line number Diff line change
Expand Up @@ -45,19 +45,32 @@ 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"}}>
</{{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>
{{yield}}
</{{@otherTagName}}>
```

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.

Expand All @@ -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.
Expand Down Expand Up @@ -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"}}>
</{{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">
...
</{{tagName}}>
{{/with}}
```
---

0 comments on commit a3b5824

Please sign in to comment.