Thanks for the quick reply.

My impression from reading the draft spec and looking at slide 28 of
Domenic's excellent presentation
( http://www.slideshare.net/domenicdenicola/es6-the-awesome-parts )

is that with your example:
…
    safe_html `<${x}>hello, ${u}</${x}>`
if this were run in a context where x is 'strong', and u is 'world', then
what would be equivalent to calling:

safe_html(
  { raw: ['<', '>hello, ', '<', '>'],
    cooked: ['<', '>hello, ', '<', '>']
  },
  'strong',
  'world',
  'strong'
);

While I can see how this is useful in many circumstances, I don't
immediately see how this enables the more conventional model of expansion
with an explicit dictionary under control of the caller.

I'd like to be able to do something like:

    function safe_html(template_string) {
        // note: mapping dictionary d constructed explicitly, not based on
what's in scope where template literal appeared
        var d = { x: 'strong', u: 'world'};
        return template_expand(template_string, d);
    }

I think this requires the expansion function to be passed the exact
template string before any processing has taken place, since even 'raw'
form removes variable references. As far as I can tell this unprocessed
form of the template string isn't made available to the expansion function
in the current draft spec.  Please let me know if I'm missing something.

Thanks,

    -Antony

On Tue Oct 28 2014 at 1:44:45 PM Brendan Eich <bren...@mozilla.org> wrote:

> Brendan Eich wrote:
> >
> >   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.
>
> Thanks to Domenic for reminding me to look harder:
>
> http://people.mozilla.org/~jorendorff/es6-draft.html#sec-tagged-templates
>
> Tagged templates are in ES6.
>
> /be
>
_______________________________________________
es-discuss mailing list
es-discuss@mozilla.org
https://mail.mozilla.org/listinfo/es-discuss

Reply via email to