A Function.tag proposal?
Andrea Giammarchi
andrea.giammarchi at gmail.com
Mon Jun 22 10:24:13 UTC 2020
This is something somehow bothering developers and tools, sooner or later,
the need for a no-op template literal tag function that just returns the
string as is.
The current workaround to have highlights, proper content minification,
etc, is the following one:
```js
import css from 'dummy-tag';import html from 'dummy-tag';
const style = css` body { color: green; }`;
const node = html` <div>hello world</div>`;
```
but as irrelevant as the dummy-tag code is, in size, it's a dependency, and
a function that can't get easily optimized, due the nature of the tag
signature.
### Proposal
Provide a static `Function.tag` which internally flattens out any template
literal content.
```js
const css = Function.tag;
const html = Function.tag;
const style = css` body { color: green; }`;
const node = html` <div>hello world</div>`;
```
Internally it will place eventual interpolations within template chunks,
and return a string.
```js
Function.tag`1${2}3` === '123';
```
That's it. Thoughts?
Best Regards
-------------- next part --------------
An HTML attachment was scrubbed...
URL: <http://mail.mozilla.org/pipermail/es-discuss/attachments/20200622/6b313a71/attachment.html>
More information about the es-discuss
mailing list