- From: Yuri Karadzhov <notifications@github.com>
- Date: Wed, 21 Feb 2018 07:58:27 +0000 (UTC)
- To: w3c/webcomponents <webcomponents@noreply.github.com>
- Cc: Subscribed <subscribed@noreply.github.com>
Received on Wednesday, 21 February 2018 07:58:49 UTC
Moreover, let's say that `html` tag from the example above are being part of the standard, then having flat html templates
```html
<div>
<h1>$$</h1>
$$
</div>
```
and
```html
<h2>Wellcome $$!</h2>
```
We can compose them into complex template with logic this way
```js
const SEPARATOR = '$$';
const template = html(tpl1.split(SEPARATOR), name, name ? html(tpl2.split(SEPARATOR), name) : '');
```
Well it is working but does not look quite good, but there is a better way to say the same, we can define a template like this
```html
<div>
<h1>${name}</h1>
${name ? html`<h2>Wellcome ${name}!</h2>` : ''}
</div>
```
And then instantiate it this way (it is dirty, but having scoped eval and native implementation will work better)
```js
const template = eval('html`' + tpl + '`');
```
--
You are receiving this because you are subscribed to this thread.
Reply to this email directly or view it on GitHub:
https://github.com/w3c/webcomponents/issues/739#issuecomment-367242213
Received on Wednesday, 21 February 2018 07:58:49 UTC