-
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
Dynamic object keys #786
Comments
I've wanted to do this, but using string interpolations. Wouldn't that be the proper way to do it rather than introducing an alternative syntax inconsistent with JavaScript?
into
|
Lexer converts interpolated strings into parenthesized concatenations, so that's actually the same thing for parser. |
I wrote that code and I don't remember it now, classic! I like the proposal, we just need to settle on a syntax (ah, the never ending discussion). |
I like the string interpolation approach. Its meaning is immediately apparent, whereas interpreting things differently when wrapped in parentheses is a bit eccentric. Can we figure out a way to get this to work in the lexer/parser? |
Note that there is a precedence. |
I like Groovy, but I still think the parentheses syntax is non-obvious. Look at it from the other direction: Isn't it odd that |
http://github.com/satyr/coffee-script/compare/master...dynakeys
Done I think.
|
Merged to master. |
Nice! |
This was pulled from master in 4447180 which was released in CoffeeScript 0.9.6 @jashkenas perhaps you should add it to the changelog |
Sure thing: 4cab45c |
What was the issue with these dynamic object keys exactly? I miss them... |
FYI
|
very true |
There may be something nice, but it is not pragmatic. Look at React's React.addons.classSet
'classA': true
'classB': hasClassB()
'classC': hasClassC() But most of the time you need dynamic keys (specially if you follow BEM), like: React.addons.classSet
"block__element#{if hasModifier() '--modifier' else '--no-modifier'}": true |
This is generating You can write a comment |
@Spadavecchia Are you sure coffeelint and and karma use coffee-script 1.9.1? |
@lidell, is true, that projects are using an old CS version, but should it to fail with version 1.7? |
yes. #3840 |
By allowing parenthesized expression as keys, we could write:
instead of:
The compilation would be:
Not sure if we can go braceless with it, but worth a try.
The text was updated successfully, but these errors were encountered: