Re: [w3c/webcomponents] HTML Modules (#645)

> But I do like the idea that there can also be some official way of inlining html templates, and style templates (and maybe other resources) in a way that the browser will optimize around, and which tooling can work with.

For inlining HTML, there are a lot of us who've come around to the idea of using something like JS template literals because of the fact that one of the main concerns with templates is intermixing values from script in the template output.

What I think would really help here is some kind of support for parsing HTML contained in template literals with a special tag, and producing an HTML template:

```javascript
@html`<div>${name}</div>`
```

(I used `@html` only because the parser would need some way to recognize the tag that's not an identifier that could be user-defined, and as of yet I don't think decorators are allowed in that position, some other sigil could be used).

There have been previous proposals around parsing inline HTML, like [E4H](https://www.hixie.ch/specs/e4h/strawman), but they preceded the `<template>` element and  missed out on the importance of templates and in-place updating of existing DOM, over the creation of new DOM.

I've implemented a template system based on this idea, plus template expression syntax discussed [here](https://github.com/whatwg/html/issues/2254): https://www.npmjs.com/package/lit-html

-- 
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/645#issuecomment-320712449

Received on Monday, 7 August 2017 16:29:20 UTC