Template strings as a template language.

Alexander Jones alex at weej.com
Sun Sep 13 13:15:03 UTC 2015

I think it would look something like this:

tag `string text ${expression} string text`
// vs.
String.templateEval("string text ${expression} string text", tag)

(Clearly, evaluation errors would be a runtime error, much like how `eval`
itself works.)

My hunch is this would be quite a useful complement to the template string
feature. It's similar in essence to constructing a RegExp using the
`RegExp` constructor instead of the literal syntax, and is a clear parallel
to `eval`.

On 13 September 2015 at 13:08, Mark S. Miller <erights at google.com> wrote:

> On Sun, Sep 13, 2015 at 2:42 AM, Thomas <thomasjamesfoster at 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 a concrete example of the boilerplate you have
> in mind and what it accomplishes?
>> or use eval after loading a file as a string it's pretty much impossible.
>> Is there a simpler way to be doing this? Or any plans for a type of eval
>> that only executes it's argument as a template string?
> I am unaware of any such plans. Could you give an example of what it looks
> like and what it would accomplish? Thanks.
> --
>     Cheers,
>     --MarkM
> _______________________________________________
> 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/20150913/86347bee/attachment.html>

More information about the es-discuss mailing list