Quasi-literals for templating?

Mark S. Miller erights at google.com
Wed Jun 15 07:54:12 PDT 2011


On Wed, Jun 15, 2011 at 2:43 AM, Axel Rauschmayer <axel at rauschma.de> wrote:

> >> Has that been considered as a use case (e.g. after a
> compilation/generation step?). But it doesn’t seem like identifier names are
> accessible to quasi handlers, which would make this difficult.
> >
> > If the consensus ends up being that more than simple identifiers are
> > allowed in substitutions, then I don't know what it would mean for
> > identifiers to be available.
>
> I didn’t find in the spec how the "substitutions" parameter (that quasi
> handlers get) is structured, thus I assumed that it was an array of values.
> It could be an array of (key,value) pairs, then going beyond simple
> identifiers would be easy. I am assuming that order matters, if not, then
> there is something fundamental about handler parameters that I haven’t
> understood.
>

Doing this by default violates alpha rename-ability.

To ease lexing worries, we simplified the quasis proposal at the last minute
from accepting (informally)

      Identifier `....${ Expression }....`

to

      Identifier `....${ IdentifierDottedPathExpression }....`

Having now tried to write quasis within this restriction, I believe we chose
too strong a restriction at this last minute and need to find some way to
relax it. More on that later.

If we relax this position back towards Expression, then, if you want to pass
such pairs, you could do so:

    foo`...${ {bar} }...${ {baz} }...`

Recall that {bar} will be syntactic sugar for {bar: bar}. So this would
expand to

    foo(literalPartsRecord, {bar: bar}, {baz: baz})



>
> Using jQuery templates to validate template support: good choice, I really
> like this templating engine.
>
> Axel
>
> --
> 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
-------------- next part --------------
An HTML attachment was scrubbed...
URL: <http://mail.mozilla.org/pipermail/es-discuss/attachments/20110615/38132cc2/attachment-0001.html>


More information about the es-discuss mailing list