sorry, early send (I think it was a ctrl+return ? ) ... I was saying ..

without using eval and already discussed months ago:
https://gist.github.com/WebReflection/8f227532143e63649804

it's based on the glorious `with` statement and it works like a charm

Regards






On Mon, Sep 14, 2015 at 11:49 AM, Andrea Giammarchi <
andrea.giammar...@gmail.com> wrote:

> without using eval, discussed already months ago
>
>
> On Mon, Sep 14, 2015 at 6:03 AM, Thomas <thomasjamesfos...@bigpond.com>
> wrote:
>
>> For those interested, this gist better shows what's being discussed:
>> https://gist.github.com/thomasfoster96/193e7c08aae499f810a1
>>
>> Ron: Yes, that's already possible - but tagged template strings don't
>> really offer much of an advantage over a function as far as templating goes
>> (IMHO).
>>
>> Thomas
>>
>> On 14 Sep 2015, at 11:04 AM, Ron Buckton <ron.buck...@microsoft.com>
>> wrote:
>>
>> This is theoretically possible:
>>
>> ```
>> let t = $template`
>>   ${$item.permalink}
>>   ${$each($item.comments)`
>>     ${$parent.permalink}
>>     ${$if($item.title)`
>>       ${$parent.permalink}
>>     `}
>>   `}
>> `;
>> let s = t(data);
>> ```
>>
>> ...given an adequate implementation using proxies (to create bindings for
>> e.g. `$item.permalink` for later evaluation) and tagged template functions.
>> Whether or not this would make for a reasonable implementation is left to
>> the reader.
>>
>> Ron
>> ------------------------------
>> From: Isiah Meadows <isiahmead...@gmail.com>
>> Sent: ‎9/‎13/‎2015 4:15 PM
>> To: Mark S. Miller <erig...@google.com>
>> Cc: Bob Myers <r...@gol.com>; es-discuss <es-discuss@mozilla.org>
>> Subject: Re: Template strings as a template language.
>>
>> On Sun, Sep 13, 2015 at 7:09 PM, Mark S. Miller <erig...@google.com>
>> wrote:
>> >
>> >
>> > On Sun, Sep 13, 2015 at 8:58 AM, Bob Myers <r...@gol.com> wrote:
>> >>
>> >> Templating languages typically "compile" templates into functions
>> through
>> >> various lexical transformations.
>> >>
>> >> Consider a template file foo.tem:
>> >>
>> >> ```
>> >> My name is ${
>> https://na01.safelinks.protection.outlook.com/?url=this.name&data=01%7c01%7cron.buckton%40microsoft.com%7ce705066eae3849ee21f008d2bc913033%7c72f988bf86f141af91ab2d7cd011db47%7c1&sdata=CY6YpX1n5jLScYGX2W1tIi2ndGlA7WI8ZTJUZjDL2Gw%3d
>> }.
>> >> ```
>> >>
>> >> Lexically transform this into
>> >>
>> >> ```
>> >> function foo() {
>> >>   return `My name is ${this.name|}.`;
>> >> }
>> >>
>> >> Then invoke the template as eg
>> >>
>> >> ```
>> >> foo.call({name: 'Bob'})
>> >> ```
>> >>
>> >> Having said that, I doubt if ES6 template strings serve as a useful
>> basis
>> >> for a full-fledged templating system. To take just one basic example,
>> how
>> >> would one implement the equivalent of `{{#if}}`?
>> >
>> >
>> > What does `{{#if}}` mean?
>> >
>>
>> An example from Handlebars' website (which is likely where he drew the
>> syntax from):
>>
>> ```
>> {{permalink}}
>> {{#each comments}}
>>   {{../permalink}}
>>
>>   {{#if title}}
>>     {{../permalink}}
>>   {{/if}}
>> {{/each}}
>> ```
>>
>>
>>
>> >>
>> >>
>> >> Bob
>> >>
>> >>
>> >> _______________________________________________
>> >> es-discuss mailing list
>> >> es-discuss@mozilla.org
>> >>
>> https://na01.safelinks.protection.outlook.com/?url=https%3a%2f%2fmail.mozilla.org%2flistinfo%2fes-discuss&data=01%7c01%7cron.buckton%40microsoft.com%7ce705066eae3849ee21f008d2bc913033%7c72f988bf86f141af91ab2d7cd011db47%7c1&sdata=Vk9C%2fonHktgLCsW%2f395PrpBWefRcs6XFqJk7HTVbunE%3d
>> >>
>> >
>> >
>> >
>> > --
>> >     Cheers,
>> >     --MarkM
>> >
>> > _______________________________________________
>> > es-discuss mailing list
>> > es-discuss@mozilla.org
>> >
>> https://na01.safelinks.protection.outlook.com/?url=https%3a%2f%2fmail.mozilla.org%2flistinfo%2fes-discuss&data=01%7c01%7cron.buckton%40microsoft.com%7ce705066eae3849ee21f008d2bc913033%7c72f988bf86f141af91ab2d7cd011db47%7c1&sdata=Vk9C%2fonHktgLCsW%2f395PrpBWefRcs6XFqJk7HTVbunE%3d
>> >
>>
>>
>>
>> --
>> Isiah Meadows
>> _______________________________________________
>> es-discuss mailing list
>> es-discuss@mozilla.org
>>
>> https://na01.safelinks.protection.outlook.com/?url=https%3a%2f%2fmail.mozilla.org%2flistinfo%2fes-discuss&data=01%7c01%7cron.buckton%40microsoft.com%7ce705066eae3849ee21f008d2bc913033%7c72f988bf86f141af91ab2d7cd011db47%7c1&sdata=Vk9C%2fonHktgLCsW%2f395PrpBWefRcs6XFqJk7HTVbunE%3d
>>
>> _______________________________________________
>> es-discuss mailing list
>> es-discuss@mozilla.org
>> https://mail.mozilla.org/listinfo/es-discuss
>>
>>
>> _______________________________________________
>> es-discuss mailing list
>> es-discuss@mozilla.org
>> https://mail.mozilla.org/listinfo/es-discuss
>>
>>
>
_______________________________________________
es-discuss mailing list
es-discuss@mozilla.org
https://mail.mozilla.org/listinfo/es-discuss

Reply via email to