Elegant way to generate string from tagged template?

Glen Huang curvedmark at gmail.com
Wed Dec 24 01:35:43 PST 2014


I think I had been doing the whole thing wrong.

Instead of doing:

```
minify`
	<ul>
		<li>${content}</li>
	</ul>
`
```

I should just do:

```
minify(`
	<ul>
		<li>${content}</li>
	</ul>
`)
```

And forget about putting the template object back into a string altogether.

> On Dec 24, 2014, at 12:44 PM, Brendan Eich <brendan at mozilla.org> wrote:
> 
> Clever -- treat the cooked values as raw. Should work -- test in Traceur?
> 
> /be
> 
> Glen Huang wrote:
>> On second thought, make it could be just as simple as this?
>> 
>> function tag(templateObj, ..args) {
>> 	return String.raw({raw: templateObj}, …args);
>> }



More information about the es-discuss mailing list