Converting strings to template strings

caridy caridy at gmail.com
Thu Mar 26 20:44:28 UTC 2015


In general, if you want to have control over those arguments, reusing the template without the need of the wrapping function, you will have to provide a way to apply logic inside the template string, that complicates things a lot.

As for i18n, ICU messages can solve that part of the puzzle providing structure and logic for complex messages. FYI we are working on a proposal for ECMA-402 to introduce `Intl.MessageFormat()` that will address i18n aspect of this.

/caridy

> On Mar 23, 2015, at 4:52 PM, Andrea Giammarchi <andrea.giammarchi at gmail.com> wrote:
> 
> Even a function wouldn't scale that well for i18n purpose, 'cause you should write either a function per language or each language switch statement per function.
> 
> I see current ES6 string templates good for debug purpose only, and not much else ... maybe English centric developers tools so few, definitively good use cases, but nothing that useful or powerful for the known Web.
> 
> ```
> 
> var template = ``Hello ${name} !``;
> 
> template({name: 'there'}); // Hello there !
> 
> ```
> 
> But I know, double back-tick might look too like double rainbow: "OMG what does it mean" ??!
> 
> Regards
> 
> 
> 
> On Mon, Mar 23, 2015 at 9:29 PM, Brendan Eich <brendan at mozilla.org <mailto:brendan at mozilla.org>> wrote:
> Jason Orendorff wrote:
> But from the few data points I have, approximately 100% of web
> developers, when they first hear "template strings are in ES6", think
> that means something like Mustache in the standard library. Some
> initially try to use the feature that way and get frustrated. I expect
> widespread confusion on this point.
> 
> This.
> 
> A function wrapped around a template string, where the function's parameters occur in embedded expressions, goes a long way. But you have to write the function, after teaching people the basics and apologizing for misleading them with the t-word.
> 
> /be
> 
> _______________________________________________
> es-discuss mailing list
> es-discuss at mozilla.org <mailto:es-discuss at mozilla.org>
> https://mail.mozilla.org/listinfo/es-discuss <https://mail.mozilla.org/listinfo/es-discuss>
> 
> _______________________________________________
> es-discuss mailing list
> es-discuss at mozilla.org
> https://mail.mozilla.org/listinfo/es-discuss

-------------- next part --------------
An HTML attachment was scrubbed...
URL: <http://mail.mozilla.org/pipermail/es-discuss/attachments/20150326/c1f9a4e6/attachment.html>


More information about the es-discuss mailing list