...and, additionally: This would allow one to encode/decode Template's in JSON notation as string primitive.
2012/9/23 Aron Homberg <[email protected]> > 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 >
_______________________________________________ es-discuss mailing list [email protected] https://mail.mozilla.org/listinfo/es-discuss

