-
Notifications
You must be signed in to change notification settings - Fork 2k
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
[CS2] Output interpolated strings as template literals #4365
[CS2] Output interpolated strings as template literals #4365
Conversation
# Uncomment the following line in CoffeeScript 2, to allow all interpolated | ||
# strings to be output using the ES2015 syntax: | ||
# unwrap: -> this | ||
#TODO: Is this needed / correct? |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
this is correct. This is needed for traverseChildren
introspection. If you don't use this, => "foo #{this}"
will not have its this
bound because that one traverseChildren wouldn't have traversed inside the interpolations.
@GeoffreyBooth and @lydell I've made the changes to output interpolated strings as template literals. Am looking for some input, as I'm lacking nodes.coffee knowledge. Specifically, StringWithInterpolations now extends Base, not Parens. Extending Parens is unnecessary, as we don't need to bracket template literals (they have clear backtick begin and end markers). Am looking for guidance on which StringWithInterpolations fields to overload from Base. I copied Parens, which overloaded Relevant lines are below. Thoughts?
|
@lydell and @jashkenas I’ve been wondering about the purpose of |
…ed-strings-as-template-literals
Explaining how that stuff works would be awesome. I struggle with it every time I touch nodes.coffee. |
I think this is roughly what some of them do:
All of the above might be used for more things as well, but that's just what I (think I) remember from the top of my head. |
The children list is the structure of the AST. The
Exactly. It's all about "do we need to cache this expression?"
Jumps tells you if an expression, or an internal part of an expression has a flow control construct (like value = if condition
100
else
return 5
Exactly. Things that If anyone wants to put any of the above into docs or further comments, feel free. |
@lydell and @jashkenas I merged your comments into https://github.com/jashkenas/coffeescript/wiki/%5BHowTo%5D-How-parsing-works |
In CS2, output interpolated strings as template literals.
Follow on work from #4352