- From: Justin Fagnani <notifications@github.com>
- Date: Mon, 18 Sep 2023 09:29:17 -0700
- To: WICG/webcomponents <webcomponents@noreply.github.com>
- Cc: Subscribed <subscribed@noreply.github.com>
Received on Monday, 18 September 2023 16:29:23 UTC
One of the reasons to not use `<` is to allow parts where those characters are not allowed, such as unquoted attribute values and inside an opening tag. Using `<` would require a different syntax for those.
Here are the places we would like to allow parts:
| Location | Example |
|---|---|
| Child node with no content | `<div>{{}}</div>` |
| Child node with content | `<div>{{#}}<p>default content</p>{{/}}</div>` |
| Unquoted attribute value | `<div foo={{}}>` |
| Quoted attribute value | `<div foo="{{}} and {{}}">` |
| Element | `<div {{}}>` |
There is a related requirement that I would like to preserve, which is that you can make a valid parts-containing template HTML string from author-provided template strings without having to parse the author-provided strings. This is possible if we can join the author-provided template strings with a single joiner string.
This makes building a declarative HTML template system in JS very easy:
```ts
const html = (strings, ...values) => {html: strings.join('{{}}'), strings, values};
const example = html`<div ${behaviorA()} foo=${valueB}>${children}</div>`;
example.html; // <div {{}} foo={{}}>{{}}</div>
```
--
Reply to this email directly or view it on GitHub:
https://github.com/WICG/webcomponents/issues/1028#issuecomment-1723894673
You are receiving this because you are subscribed to this thread.
Message ID: <WICG/webcomponents/issues/1028/1723894673@github.com>
Received on Monday, 18 September 2023 16:29:23 UTC