New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Add support for arbitrary code inside template tags #279

Closed
manuel-di-iorio opened this Issue Jan 10, 2016 · 6 comments

Comments

Projects
None yet
4 participants
@manuel-di-iorio

manuel-di-iorio commented Jan 10, 2016

Why not support any arbitrary code inside template strings expressions?

This is not supported i.e:

`${ if (a == 2) {
    console.log('hi');
} }`

And with more complex code, like if, if-else, for loops, etc..

It would be nice to develop a template engine that uses this native approach instead of a string manipulation.

@michaelficarra

This comment has been minimized.

Show comment
Hide comment
@michaelficarra

michaelficarra Jan 10, 2016

Member

Do-expressions will allow this:

`${ do if (a == 2) {
    console.log('hi');
} }`
Member

michaelficarra commented Jan 10, 2016

Do-expressions will allow this:

`${ do if (a == 2) {
    console.log('hi');
} }`
@manuel-di-iorio

This comment has been minimized.

Show comment
Hide comment
@manuel-di-iorio

manuel-di-iorio Jan 10, 2016

Awesome! Can I ask why the do keyword ?
And something like the following will be supported?

`${ Hello do if (a == 2) {
    console.log(' world');
} }`
//will output: Hello world

manuel-di-iorio commented Jan 10, 2016

Awesome! Can I ask why the do keyword ?
And something like the following will be supported?

`${ Hello do if (a == 2) {
    console.log(' world');
} }`
//will output: Hello world
@michaelficarra

This comment has been minimized.

Show comment
Hide comment
@michaelficarra

michaelficarra Jan 10, 2016

Member

No, not at all. There's many things wrong with what you've written. "Hello " needs to be a literal part of the template, the completion value of the if statement is either null (the return value of console.log) or undefined, and in order to see the value produced by the template, it all needs to be within the argument list for console.log.

It seems you are very unfamiliar with JavaScript. I would recommend asking questions like this on Stack Overflow or some other medium. This issue tracker is meant for a different kind of discussion.

Member

michaelficarra commented Jan 10, 2016

No, not at all. There's many things wrong with what you've written. "Hello " needs to be a literal part of the template, the completion value of the if statement is either null (the return value of console.log) or undefined, and in order to see the value produced by the template, it all needs to be within the argument list for console.log.

It seems you are very unfamiliar with JavaScript. I would recommend asking questions like this on Stack Overflow or some other medium. This issue tracker is meant for a different kind of discussion.

@domenic

This comment has been minimized.

Show comment
Hide comment
@domenic

domenic Jan 10, 2016

Member

Per https://github.com/tc39/ecma262/blob/master/CONTRIBUTING.md#feature-requests, closing this. @michaelficarra perhaps in the future redirect to StackOverflow sooner instead of indulging people :)

Member

domenic commented Jan 10, 2016

Per https://github.com/tc39/ecma262/blob/master/CONTRIBUTING.md#feature-requests, closing this. @michaelficarra perhaps in the future redirect to StackOverflow sooner instead of indulging people :)

@domenic domenic closed this Jan 10, 2016

@manuel-di-iorio

This comment has been minimized.

Show comment
Hide comment
@manuel-di-iorio

manuel-di-iorio Jan 10, 2016

Sorry previously I made a typo.. I meant:

`Hello ${ do if (a == 2) {
    console.log(' world');
} }`

@michaelficarra nope I already asked on SO and they redirected me here.. However the issue is now closed and I'm happy with the feature proposal. Hope to see its availability as soon as possible :)

manuel-di-iorio commented Jan 10, 2016

Sorry previously I made a typo.. I meant:

`Hello ${ do if (a == 2) {
    console.log(' world');
} }`

@michaelficarra nope I already asked on SO and they redirected me here.. However the issue is now closed and I'm happy with the feature proposal. Hope to see its availability as soon as possible :)

@h4ckninja

This comment has been minimized.

Show comment
Hide comment
@h4ckninja

h4ckninja Jan 10, 2016

I'm not the micheal you are looking for. :)

h4ckninja commented Jan 10, 2016

I'm not the micheal you are looking for. :)

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment