how to delay interpolation of template strings?

Niloy Mondal niloy.mondal84 at gmail.com
Tue Dec 16 02:01:24 PST 2014


Thanks, this would work.

How can I construct a template string dynamically? Like reading the
template from a file/database and then interpolate it.

On Tue, Dec 16, 2014 at 2:29 PM, Claude Pache <claude.pache at gmail.com>
wrote:
>
>
> Le 16 déc. 2014 à 09:27, Niloy Mondal <niloy.mondal84 at gmail.com> a écrit :
>
> I want to define a template string using backquotes in a different file
> and then have it interpolated with actual values in a different file. How
> can I do it?
>
>
> Just enclose it in a function:
>
> ```javascript
>    function foo(a) {
>         return `some template ${a}`
>     }
>
>     foo("bar") // will evaluate `some template ${"bar"}`
> ```
>
> —Claude
>
-------------- next part --------------
An HTML attachment was scrubbed...
URL: <http://mail.mozilla.org/pipermail/es-discuss/attachments/20141216/19a1d90c/attachment-0001.html>


More information about the es-discuss mailing list