Template strings and templates

Axel Rauschmayer axel at rauschma.de
Fri Aug 3 11:24:33 PDT 2012


> let tmpl = addresses => html`
>   <table>
>   ${addresses.forEach(address=>
>           html`<tr>${address.first}</tr><tr>${address.last}</tr>`
>       ).join('\n')
>   }
>   </table>`
> 
> would be my guess? Similarly for the localization example
> in the blog post: arrow functions should make it relatively painless to make the template parameters explicit.
> 
> Of course, building HTML from nested templates is not the
> same as filling a flat HTML template with user input, so I'm
> not sure what the implicit encoding of template parameters
> will do to this approach. 

Nice. I’d let the html handler do the join, then it’s even shorter. That is: If a substitution is an array of strings, it joins, otherwise it coerces to string.

-- 
Dr. Axel Rauschmayer
axel at rauschma.de

home: rauschma.de
twitter: twitter.com/rauschma
blog: 2ality.com

-------------- next part --------------
An HTML attachment was scrubbed...
URL: <http://mail.mozilla.org/pipermail/es-discuss/attachments/20120803/f5a138a2/attachment.html>


More information about the es-discuss mailing list