Antony Courtney wrote:
expand(`Hello ${x} and ${y}!`, {x: 10, y: 12});
// ==> Hello 10 and 12!
From what I've seen of drafts of ES6 template strings, templates are
expanded automatically by evaluating the expressions enclosed in
${...} at the point where the template string literal appears.
Do ES6 templates offer this more conventional, explicit,
programmer-controlled form of expansion in any form?
Yes, or least this was part of the template strings proposal for ES6 --
you'd prepend the name of your expand function to the ``-delimited
template string:
safe_html `<${x}>hello, ${u}</${x}>`
But you're right, the
http://people.mozilla.org/~jorendorff/es6-draft.html copy I'm finding
"template" in online does not include this prefix form. Did it get cut
from ES6? I thought the only debate was whether to include unprefixed
templates. I'm no doubt forgetting something, so cc'ing Allen.
/be
_______________________________________________
es-discuss mailing list
[email protected]
https://mail.mozilla.org/listinfo/es-discuss