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
Disambiguate if expressions in rsx by requiring curlies, allow shorthand component/element initialization #1810
Conversation
// ``` | ||
// match { | ||
// val => div {} | ||
// other_val => div {} |
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.
I think allowing you to do normal rsx elements in match arms would be more consistant with if statements and loops in the future, but it could be in a different PR
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.
Looks good! Excited for better autocomplete
This PR changes how rsx interprets expressions, requiring them to be wrapped in curly braces.
This is a hugely breaking PR but allows a number of goodies like letting us keep consistency of if/for special cases and shorthand struct initialization.
It could also lead the way to improved autocomplete via partial expansion, however this is not yet implemented.
In it's current form it provides way better autocomplete when working inside curly braces and better autocomplete of attributes and props.
So, this works now:
And so does this:
This also supports elements:
However we don't special-case children and currently panic if an attribute named "children" is present.
In theory we could accept the
children
argument in elements, but I just didn't get around to it here.