Quasi-literals for templating?

Mark S. Miller erights at google.com
Wed Jun 15 16:43:27 PDT 2011


On Wed, Jun 15, 2011 at 4:42 PM, Axel Rauschmayer <axel at rauschma.de> wrote:

> Ah, very clever. It’d be nice to have an example of using this to compile
> templates (like jQuery templates). Maybe not even the implementation, just a
> quasi literal and why it works.
>
> var myTmpl = tmpl`Dear ${{first}} ${{last}}`; // (*)
> alert(myTempl.render({ first: "Jane", last: "Doe" }));
>
> The handler (at (*)) is called like this:
> tmpl(callSiteId73654, { first: undefined }, { last: undefined });
>
> BTW: won’t it be a problem (for this use case) if the variables first and
> last don’t exist?
>

It would indeed be a problem. How much does this matter?



>
> On Jun 16, 2011, at 1:31 , Mark S. Miller wrote:
>
>
>
> On Wed, Jun 15, 2011 at 4:16 PM, Axel Rauschmayer <axel at rauschma.de>wrote:
>
>> Quick feedback: I haven’t seen SVE (substitution value expression?)
>> defined anywhere and can’t find a description of using ${{var}} as syntactic
>> sugar for "{var:${var}}".
>>
>
> At <http://wiki.ecmascript.org/doku.php?id=harmony:destructuring#issues>:
>
> The shorthand {x, y} for {x: x, y: y} allowed on the left-hand side of
> assignment should be allowed on the right too ...
>
> This shorthand has nothing to do with quasis per se. It's just a convenient
> expression syntax. So if we allow more expression syntaxes to appear between
> `...${ and }...` and if this "more" includes this specific syntax, then we
> can compose then to give the requested information conveniently without
> violating alpha-rename-ability.
>
>
>
>>
>>
>> On Jun 15, 2011, at 20:42 , Mike Samuel wrote:
>>
>> > 2011/6/15 Brendan Eich <brendan at mozilla.com>:
>> >> The point is that the callSiteId captures all the
>> literal/constant/loop-invariant parts of the quasi, both raw and cooked
>> ("expandedLP"). The remaining quasi handler parameters are the necessarily
>> variable, evaluated-at-runtime substitution expression results.
>> >>
>> >> The proposal needs to say this a bit more explicitly, and up front.
>> >
>> > Added http://wiki.ecmascript.org/doku.php?id=harmony:quasis#callsiteid
>> > and renamed rawLP and unescapedLP.
>> >
>>
>> --
>> Dr. Axel Rauschmayer
>>
>> axel at rauschma.de
>> twitter.com/rauschma
>>
>> home: rauschma.de
>> blog: 2ality.com
>>
>>
>>
>> _______________________________________________
>> es-discuss mailing list
>> es-discuss at mozilla.org
>> https://mail.mozilla.org/listinfo/es-discuss
>>
>
>
>
> --
>     Cheers,
>     --MarkM
>
>
> --
> Dr. Axel Rauschmayer
>
> axel at rauschma.de
> twitter.com/rauschma
>
> home: rauschma.de
> blog: 2ality.com
>
>
>
>


-- 
    Cheers,
    --MarkM
-------------- next part --------------
An HTML attachment was scrubbed...
URL: <http://mail.mozilla.org/pipermail/es-discuss/attachments/20110615/1f0232fc/attachment-0001.html>


More information about the es-discuss mailing list