Quasi literal function call syntax

Aron Homberg info at aron-homberg.de
Sun Sep 23 15:02:46 PDT 2012


...and, additionally: This would allow one to encode/decode Template's in
JSON notation as string primitive.

2012/9/23 Aron Homberg <info at aron-homberg.de>

> Ahmn, yeah - missed the mails in between, to be precise:
>
>
> Sounds great.
>
> Just an idea to extend your idea a little bit, combining with mine:
>
> What if `whatever ${test} foo` would just construct an object of Template?
> The Template object prototype could look lile this:
>
>
> // In ES harmony syntax :)
> Template.prototype = {
>
>     toString() {...},
>     getParts() {...},
>     getValues() {...},
>     ...
> }
>
> etc. pp.
>
> This would normally lead to an implicit string conversion (toString())
> where it's needed e.g. if you do something like that:
>
>     whatever.innerHTML = `foo {$bar}`;
>
> And you can use the full power of Templates when calling a function in
> standard way: safehtml(`foo ${bar}`) where the first argument would be an
> object representing the Template prototype + Template value initialized by
> the constructor.
>
> Or you could construct a Template like this: new Template('foo ${bar}');
> or Template('foo ${bar}')
>
> This way Template's would be straight forward to use and can be
> implemented without any additional grammar magic.
> It would also lead to a late/delayed binding / rendering of the template -
> if toString() is called, not when the Template object is created which may
> be useful for performance too.
>
>
> What do you think?
>
> Thanks and regards,
> Aron
>
-------------- next part --------------
An HTML attachment was scrubbed...
URL: <http://mail.mozilla.org/pipermail/es-discuss/attachments/20120924/d4fb2b78/attachment.html>


More information about the es-discuss mailing list