-
Notifications
You must be signed in to change notification settings - Fork 11.1k
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
[10.x] Introduce short-hand "false" syntax for Blade component props #48084
[10.x] Introduce short-hand "false" syntax for Blade component props #48084
Conversation
this seems to me more similar to css |
Smart! |
I support this implementation. "Falsy" props were one of our concerns when making blade components. We have to work around this by making every boolean props to be false, and add them manually when the component is needed. This PR allowed us to refactor some of those falsies to truthy by default. |
@ryangjchandler Why don't you use the short-hand: <x-layout /> It's better to let the user add the behavior they need, rather than forcing them to remove a default one. |
@taylorotwel @driesvints This will fail to parse in some cases, e.g: <x-test :value="$value && !old('value')" /> |
I'm on vacation until Wednesday, maybe worth reverting the merge before tomorrows release so I can take a look at it & add in some test cases. @aguingand have you physically confirmed that the RegEx currently parses incorrectly for that example case? |
Done: #48220 |
I understand the reasoning behind short syntaxes but it'll need a rework of how attributes are parsed. The <x-test :value="$value ? $yes :$no" /> |
FYI, I am going to revisit this in the week. Been slammed with work since getting back from vacation! |
Currently, setting the value of a Blade component prop to
false
can only be done with the binding syntax.This syntax is quite verbose for something so simple, so this pull request introduces a new short-hand syntax.
The syntax is similar to the "not" operation in regular PHP code and feels quite familiar.