Template strings and templates

Claus Reinke claus.reinke at talk21.com
Fri Aug 3 13:08:27 PDT 2012


>> let tmpl = addresses => html`
>>    <table>
>>    ${addresses.forEach(address=>
>>            html`<tr>${address.first}</tr><tr>${address.last}</tr>`
>>        ).join('\n')
>>    }
>>    </table>`
>>
> 
> Yes. But you need to say ".map(" rather than ".forEach(" above. See
> <http://wiki.ecmascript.org/doku.php?id=harmony:quasis#nesting>.

Oops, yes!

> Thanks for pointing out how much fat arrows help for this use case. I
> knew it would help but hadn't expected it to help that much. Nice!

Anything that helps to convince people that arrow functions are
not just an odd way of writing functions for people who don't
like to type;-)

Btw, the negative experience with Haskell's "monads" terminology
shows that choosing a scary name can hamper the adoption of even 
the most useful language features. So switching to "template strings" 
is a good idea. We do need to communicate that they are not limited 
to strings, though: template parameters and tag results can be
arbitrary ES objects/values.

Claus
 


More information about the es-discuss mailing list