I think it would look something like this:

```js
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 <[email protected]> wrote:

> On Sun, Sep 13, 2015 at 2:42 AM, Thomas <[email protected]>
> 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
> [email protected]
> https://mail.mozilla.org/listinfo/es-discuss
>
>
_______________________________________________
es-discuss mailing list
[email protected]
https://mail.mozilla.org/listinfo/es-discuss

Reply via email to