Re: Template strings and templates

2014-03-07 Thread Andreas Rossberg
On 7 March 2014 08:40, Axel Rauschmayer a...@rauschma.de wrote: // Localization and formatting l10n`Hello ${name}; you are visitor number ${visitor}:n! You have ${money}:c in your account!` A correct German translation of this would have to take the gender of the visitor into consideration:

Re: Template strings and templates

2014-03-07 Thread Mark Volkmann
It seems to me that the main benefit is that it takes care of parsing out the template parts around the expressions for you. Otherwise you might write a regular expression to do that. --- R. Mark Volkmann Object Computing, Inc. On Mar 6, 2014, at 5:29 PM, Caitlin Potter caitpotte...@gmail.com

Re: Re: Template strings and templates

2014-03-06 Thread Caitlin Potter
What exactly is being accomplished with tagged templates? I mean, what is the use case? It seems to make certain specific function calls look very different from a typical function call, the arguments passed in are not very clearly explained in the draft or wiki, and I have difficulty imagining

Re: Template strings and templates

2014-03-06 Thread Axel Rauschmayer
– Regular expressions: https://gist.github.com/slevithan/4222600 – Escaping the variable parts of domain-specific languages – HTML templates (think Facebook’s React) – Internationalization Axel On Mar 7, 2014, at 0:29 , Caitlin Potter caitpotte...@gmail.com wrote: What exactly is being

RE: Template strings and templates

2014-03-06 Thread Aaron Powell
On the point of DLS's, are there any example points like the regex one you posted Axel? I'm curious as to how you would do the transform Subject: Re: Template strings and templates From: a...@rauschma.de Date: Fri, 7 Mar 2014 00:46:53 +0100 To: caitpotte...@gmail.com CC: es-discuss@mozilla.org

Re: Template strings and templates

2014-03-06 Thread C. Scott Ananian
How about: ```js cs = require('coffee-script').compile; eval(cs` gcd = (x,y) - [x,y] = [y,x%y] until y is 0; x `); ``` Presumably coffee-script counts as a (large!) DSL. --scott ___ es-discuss mailing list es-discuss@mozilla.org

RE: Template strings and templates

2014-03-06 Thread Domenic Denicola
://www.slideshare.net/domenicdenicola/es6-the-awesome-parts/23 From: es-discuss [mailto:es-discuss-boun...@mozilla.org] On Behalf Of Aaron Powell Sent: Thursday, March 6, 2014 19:28 To: Axel Rauschmayer; Caitlin Potter Cc: es-discuss list Subject: RE: Template strings and templates On the point

Re: Template strings and templates

2014-03-06 Thread Norbert Lindenberg
On Mar 6, 2014, at 15:46 , Axel Rauschmayer a...@rauschma.de wrote: – Regular expressions: https://gist.github.com/slevithan/4222600 – Escaping the variable parts of domain-specific languages – HTML templates (think Facebook’s React) – Internationalization Not internationalization. The

Re: Template strings and templates

2014-03-06 Thread Axel Rauschmayer
// Localization and formatting l10n`Hello ${name}; you are visitor number ${visitor}:n! You have ${money}:c in your account!` A correct German translation of this would have to take the gender of the visitor into consideration: Male: l10n`Hallo, Herr ${name}; Sie sind Besucher Nummer

Re: Template strings and templates

2012-08-05 Thread Axel Rauschmayer
Perhaps “string template” would actually be better than “template string”: “template” makes sense as “something to fill in” (that is *not* a string, because it can be highly structured, via nesting etc.) and “string” makes sense, because the blanks to fill in are surrounded by strings. The only

Re: Template strings and templates

2012-08-05 Thread John J Barton
On Sat, Aug 4, 2012 at 1:22 PM, Mark Miller erig...@gmail.com wrote: It is a matter of definition and taste, but I don't think it is useful to think of these as macros. I expect macros to extend the base language as if adding new special forms, where these special forms are stylistically

Re: Template strings and templates

2012-08-05 Thread Claus Reinke
need to communicate that they are not limited to strings, though: template parameters and tag results can be arbitrary ES objects/values. I chose template string over string template to emphasize that it was a template that was expressed as a string rather than a template for a string. That

Re: Template strings and templates

2012-08-04 Thread John J Barton
}literal` macro`literal${substitution}literal` The default or passthru macro applies when the developer does not supply a macro. Or if you prefer macro_function`a macro with ${substitution} here` Then we don't have to spend several years explaining how template strings are templates

Re: Template strings and templates

2012-08-04 Thread Mark Miller
} here` Then we don't have to spend several years explaining how template strings are templates but not templates and aren't string templates because they take non-string substitutions. (IMO oxymoronic quasi-literal is embarrassing). jjb

Re: Template strings and templates

2012-08-04 Thread Brendan Eich
Mark Miller wrote: For quasi-literals, first, I agree that quasi anything is not a good choice and that string template is better. s/string template/template string/ ;-) /be ___ es-discuss mailing list es-discuss@mozilla.org

Re: Template strings and templates

2012-08-03 Thread Claus Reinke
let tmpl = html` table $for address in addresses ${ html`tr${first}/trtr${last}/tr` } /table`; let tmpl = addresses = html` table ${addresses.forEach(address= html`tr${address.first}/trtr${address.last}/tr` ).join('\n') } /table`

Re: Template strings and templates

2012-08-03 Thread Mark S. Miller
On Fri, Aug 3, 2012 at 1:25 AM, Claus Reinke claus.rei...@talk21.com wrote: let tmpl = html` table $for address in addresses ${ html`tr${first}/trtr${last}/tr` } /table`; let tmpl = addresses = html` table ${addresses.forEach(address=

Re: Template strings and templates

2012-08-03 Thread Allen Wirfs-Brock
On Aug 2, 2012, at 12:02 PM, Axel Rauschmayer wrote: I love the new name “template strings” for “quasi literals”. Only “tag” seem inferior to “quasi handler”, because that former term is already used in HTML. I didn't intentionally rename quasi handler to tag. I titled the section of the

Re: Template strings and templates

2012-08-03 Thread Axel Rauschmayer
let tmpl = addresses = html` table ${addresses.forEach(address= html`tr${address.first}/trtr${address.last}/tr` ).join('\n') } /table` would be my guess? Similarly for the localization example in the blog post: arrow functions should make it relatively painless

Re: Template strings and templates

2012-08-03 Thread Claus Reinke
let tmpl = addresses = html` table ${addresses.forEach(address= html`tr${address.first}/trtr${address.last}/tr` ).join('\n') } /table` Yes. But you need to say .map( rather than .forEach( above. See http://wiki.ecmascript.org/doku.php?id=harmony:quasis#nesting.

Re: Template strings and templates

2012-08-03 Thread Allen Wirfs-Brock
On Aug 3, 2012, at 1:08 PM, Claus Reinke wrote: Btw, the negative experience with Haskell's monads terminology shows that choosing a scary name can hamper the adoption of even the most useful language features. So switching to template strings is a good idea. We do need to communicate

Re: Template strings and templates

2012-08-03 Thread Axel Rauschmayer
Not sure that something better than “template string” exists. It would have to be something that describes the construct well: It is an interesting hybrid between a literal (such as a regular expression) and a function call. On Aug 3, 2012, at 23:38 , Allen Wirfs-Brock al...@wirfs-brock.com

Re: Template strings and templates

2012-08-03 Thread Axel Rauschmayer
Ah, OK. Spitballing: A synonym of tag then, maybe? Alas, label is out. If the term was, say, “mark” then one could conceivably say “mark function” instead of handler. On Aug 3, 2012, at 17:52 , Allen Wirfs-Brock al...@wirfs-brock.com wrote: Only “tag” seem inferior to “quasi handler”,

Template strings and templates

2012-08-02 Thread Axel Rauschmayer
I love the new name “template strings” for “quasi literals”. Only “tag” seem inferior to “quasi handler”, because that former term is already used in HTML. Template strings are not ideally suited for templates (think Mustache), as expressed by Nicholas Zakas [1]. Any ideas for helping here? The