Re: Template strings as a template language

2015-09-15 Thread Isiah Meadows
Sent with the wrong subject... On Tue, Sep 15, 2015 at 7:03 PM, Isiah Meadows wrote: > I think you forgot to change the subject/strip other content/etc. ;) > > Plus, I learned the hard way myself that it's easier to have my > subscription set to forward everything. It's

Re: Template strings as a template language.

2015-09-15 Thread Bob Myers
May be getting off-topic here, but I wonder why we need templating languages at all in this day and age. Originally templating systems were developed for server-centric applications such as PHP etc. which generate HTML and blast it down to the client, as a way to untangle program logic and display

Re: Template strings as a template language.

2015-09-15 Thread Andrea Giammarchi
Bob, not sure why you think template means HTML, in my case the main problem I have in JS is the absence of basic `printf` like syntax so that I can build at runtime any kind of i18n string passing an object, without needing to have the string evaluated in place, which is the strength of ES6

Re: Template strings as a template language.

2015-09-15 Thread Herby Vojčík
; >>>>>>> > >>>>>>> On 14 Sep 2015, at 11:04 AM, Ron Buckton > <ron.buck...@microsoft.com> wrote: > >>>>>>> > >>>>>>>> This is theoretically possible: > >>>>>>>> > >>&

Re: Template strings as a template language.

2015-09-15 Thread Herby Vojčík
;> 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 > > >>>&g

Re: Template strings as a template language.

2015-09-15 Thread Andrea Giammarchi
I don't think there's any risk in using my initial gist based on `Function` and `with` ... really. You should **never** pass within `${parts}` user inputs, you just pas there a variable name, or you reach a property. ```js var str = 'my ${gist}'; str.template({gist: 'window.alert(123)'}); // my

Re: Template strings as a template language.

2015-09-15 Thread Thomas
> On 16 Sep 2015, at 12:39 AM, Claude Pache wrote: > > That doesn't make much sense, because regexpes are first-class objects, while > template literals are syntax. > > The nearest equivalent of the string-to-regexp feature is the string-to-code > conversion facility

Re: Template strings as a template language.

2015-09-15 Thread Andrea Giammarchi
ally 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...@mic

Re: Template strings as a template language.

2015-09-15 Thread Herby Vojčík
ig...@google.com> Cc: Bob Myers <mailto:r...@gol.com>; es-discuss <mailto:es-discuss@mozilla.org> Subject: Re: Template strings as a template language.

Re: Template strings as a template language.

2015-09-15 Thread Edwin Reynoso
This seems to be the same thing I posted before as [String.substitute()]( https://esdiscuss.org/topic/string-substitute) I guess I didn't explain correctly, but ayy I'm glad you guys are discussing this. On Tue, Sep 15, 2015 at 10:39 AM, Claude Pache wrote: > > Le 15

Re: Template strings as a template language.

2015-09-15 Thread Claude Pache
> Le 15 sept. 2015 à 14:02, Herby Vojčík a écrit : > > > > Andrea Giammarchi wrote: >> Yet it doesn't play well with i18n since arguments passed to the IIFE >> would still come from the current local scope. RegExp would play nicer > > Oh, I meant it other way, my dense

Re: Template strings as a template language.

2015-09-14 Thread Andrea Giammarchi
aluation) 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:

Re: Template strings as a template language.

2015-09-14 Thread Andrea Giammarchi
hmead...@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, Mar

Re: Template strings as a template language.

2015-09-14 Thread Andrea Giammarchi
or 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 >>> >>>

Re: Template strings as a template language.

2015-09-14 Thread Herby Vojčík
ig...@google.com> Cc: Bob Myers <mailto:r...@gol.com>; es-discuss <mailto: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 <mailto:erig...@

Re: Template strings as a template language.

2015-09-14 Thread Thomas
gt;>>> 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

Re: Template strings as a template language.

2015-09-14 Thread Andrea Giammarchi
o 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 >>> -- >&g

Re: Template strings as a template language.

2015-09-14 Thread Thomas
>>> ${$each($item.comments)` >>>>>> ${$parent.permalink} >>>>>> ${$if($item.title)` >>>>>> ${$parent.permalink} >>>>>> `} >>>>>> `} >>>>>> `; >>>>>&g

Re: Template strings as a template language.

2015-09-14 Thread Andrea Giammarchi
k} >>>> ${$if($item.title)` >>>> ${$parent.permalink} >>>> `} >>>> `} >>>> `; >>>> let s = t(data); >>>> ``` >>>> >>>> ...given an adequate implementation using proxies (to cre

Re: Template strings as a template language.

2015-09-14 Thread Thomas
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 <

Template strings as a template language.

2015-09-13 Thread Thomas
I'd really like to use Template strings as a templating language, but unless I include a lot of boilerplate code (export a template string wrapped in a function from a file) or use eval after loading a file as a string it's pretty much impossible. Is there a simpler way to be doing

Re: Template strings as a template language.

2015-09-13 Thread Thomas
;> * I'm aware that someone could still put something inside a template string >> and do nasty stuff, but I'm not sure if that's a easily solved problem. >> >>> On 13 Sep 2015, at 10:08 PM, Mark S. Miller <erig...@google.com> wrote: >>> >>>> On S

Re: Template strings as a template language.

2015-09-13 Thread Alexander Jones
t; Thomas >> >> * I'm aware that someone could still put something inside a template >> string and do nasty stuff, but I'm not sure if that's a easily solved >> problem. >> >> On 13 Sep 2015, at 10:08 PM, Mark S. Miller <erig...@google.com> wrote: >> >&

Re: Template strings as a template language.

2015-09-13 Thread Alexander Jones
, Sep 13, 2015 at 2:42 AM, Thomas <thomasjamesfos...@bigpond.com> > wrote: > >> I'd really like to use Template strings as a templating language, but >> unless I include a lot of boilerplate code (export a template string >> wrapped in a function from a file) &

Re: Template strings as a template language.

2015-09-13 Thread Thomas
homas <thomasjamesfos...@bigpond.com> >> wrote: >> I'd really like to use Template strings as a templating language, but unless >> I include a lot of boilerplate code (export a template string wrapped in a >> function from a file) > > Hi Thomas, could you give

Re: Template strings as a template language.

2015-09-13 Thread Mark S. Miller
that someone could still put something inside a template > string and do nasty stuff, but I'm not sure if that's a easily solved > problem. > > On 13 Sep 2015, at 10:08 PM, Mark S. Miller <erig...@google.com> wrote: > > On Sun, Sep 13, 2015 at 2:42 AM, Thomas <thomasj

Re: Template strings as a template language.

2015-09-13 Thread Mark S. Miller
On Sun, Sep 13, 2015 at 2:42 AM, Thomas <thomasjamesfos...@bigpond.com> wrote: > I'd really like to use Template strings as a templating language, but > unless I include a lot of boilerplate code (export a template string > wrapped in a function from a file) Hi Thomas, could you

Re: Template strings as a template language.

2015-09-13 Thread Mark S. Miller
>>> >>> Thomas >>> >>> * I'm aware that someone could still put something inside a template >>> string and do nasty stuff, but I'm not sure if that's a easily solved >>> problem. >>> >>> On 13 Sep 2015, at 10:08 PM, Mark S. M

Re: Template strings as a template language.

2015-09-13 Thread Alexander Jones
ince it's possible for input to >>>> prematurely end the template string and do nasty stuff*. Ideally there >>>> would be a variant of eval where the string to be evaluated must be a >>>> template string expression. >>>> >>>> Thomas >>

Re: Template strings as a template language.

2015-09-13 Thread Thomas
n. >>>> >>>> Thomas >>>> >>>> * I'm aware that someone could still put something inside a template >>>> string and do nasty stuff, but I'm not sure if that's a easily solved >>>> problem. >>>> >>>&g

Re: Template strings as a template language.

2015-09-13 Thread Mark S. Miller
template >> string and do nasty stuff, but I'm not sure if that's a easily solved >> problem. >> >> On 13 Sep 2015, at 10:08 PM, Mark S. Miller <erig...@google.com> wrote: >> >> On Sun, Sep 13, 2015 at 2:42 AM, Thomas <thomasjamesfos...@bigpond.com&

Re: Template strings as a template language.

2015-09-13 Thread Thomas
> On 14 Sep 2015, at 1:38 AM, Alexander Jones wrote: > > Not exactly sure what you mean. But if you are you asking how > > ```js > let template = 'this ${foo} and that ${bar}'; > // later... > let output = String.evalTemplate(template, {foo: "thing", bar: "other > thing"}); >

Re: Template strings as a template language.

2015-09-13 Thread Mark S. Miller
On Sun, Sep 13, 2015 at 8:58 AM, Bob Myers wrote: > Templating languages typically "compile" templates into functions through > various lexical transformations. > > Consider a template file foo.tem: > > ``` > My name is ${this.name}. > ``` > > Lexically transform this into > > ```

RE: Template strings as a template language.

2015-09-13 Thread Ron Buckton
Miller<mailto:erig...@google.com> Cc: Bob Myers<mailto:r...@gol.com>; es-discuss<mailto: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

Re: Template strings as a template language.

2015-09-13 Thread Isiah Meadows
On Sun, Sep 13, 2015 at 7:09 PM, Mark S. Miller wrote: > > > On Sun, Sep 13, 2015 at 8:58 AM, Bob Myers wrote: >> >> Templating languages typically "compile" templates into functions through >> various lexical transformations. >> >> Consider a template file

Re: Template strings as a template language.

2015-09-13 Thread Thomas
le implementation is left to the > reader. > > Ron > From: Isiah Meadows > Sent: ‎9/‎13/‎2015 4:15 PM > To: Mark S. Miller > Cc: Bob Myers; es-discuss > Subject: Re: Template strings as a template language. > > On Sun, Sep 13, 2015 at 7:09 PM, Mark S. Miller <eri