Watch your precedence, Caitlin. You'll need to wrap that arrow in
parentheses like so:
```js
`Hello ${(_ => {
if (a == 2) {
console.log(‘world’);
}
})()}`;
```
Michael
On Sun, Jan 10, 2016 at 7:12 PM, Caitlin Potter <[email protected]>
wrote:
> Do-Expressions are still floating around Stage 0, there’s no guarantee
> that they will be incorporated into the language.
>
> The feature is implemented in v8 behind a flag, and can be used in Chrome
> Canary by launching the browser with `—js-flags=“—harmony-do-expressions”`,
> which would enable you to try it out.
>
> **INTERMISSION — Slightly more on-topic portion of post follows after a
> short coffee break**
>
> However, to answer your question, you can implement an
> immediately-invoked-function-expression, like this:
>
> ```js
> `Hello ${_ => {
> if (a == 2) {
> console.log(‘world’);
> }
> }()}`;
> ```
>
> So this wouldn’t depend on the Do-Expressions proposal, and wouldn’t
> require a keyword per se, although you’d still have some extra tokens
> making things a bit harder to read.
>
> It’s unlikely that the grammar would be changed to accommodate this use
> case, given that people are using template literals already, and the
> use-case is already supported by other means.
>
> On Jan 10, 2016, at 9:23 PM, Manuel Di Iorio <[email protected]> wrote:
>
> Hi, I asked around and somebody said that there will be the possibility to
> execute arbitrary code inside the template tags, using the *'do'* keyword
> in this example way:
>
> `Hello ${ do if (a == 2) {
>> console.log(' world');
>> } }`
>
>
> Is there the possibility in future to implement that feature without the
> keyword?
> What is the plan *(read 'estimated date')* for the rollout of this
> feature ?
>
> The idea to develop in native way a good templating engine is exciting and
> I'm looking forward for its complete implementation :)
> _______________________________________________
> 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
>
>
--
Shape Security is hiring outstanding individuals. Check us out at
*https://shapesecurity.com/jobs/
<https://shapesecurity.com/jobs/>*
_______________________________________________
es-discuss mailing list
[email protected]
https://mail.mozilla.org/listinfo/es-discuss