Skip to content

[9.x] Short attribute syntax for Blade Components #44217

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

Merged
merged 3 commits into from
Sep 21, 2022
Merged

[9.x] Short attribute syntax for Blade Components #44217

merged 3 commits into from
Sep 21, 2022

Conversation

pascalbaljet
Copy link
Contributor

This PR implements Caleb's proposal to optionally allow a shorter syntax for passing attributes to Blade Components.

<!-- current syntax -->
<x-profile :user-id="$userId"></x-profile>

<!-- short syntax -->
<x-profile :$userId></x-profile>

@taylorotwell taylorotwell merged commit 717618a into laravel:9.x Sep 21, 2022
@clementmas
Copy link
Contributor

<x-profile :$userId />

@olivM
Copy link

olivM commented Sep 29, 2022

it seems like it doesn't work for anonymous component (component with only a Blade template and no class)

@PerryvanderMeer
Copy link
Contributor

PerryvanderMeer commented Oct 1, 2022

It does work for anonymous components, but only for non-self-closing notations.
E.g.:

<!-- works... -->
<x-profile :$userId></x-profile>

<!-- broken... -->
<x-profile :$userId/>

@olivM
Copy link

olivM commented Oct 1, 2022

is there a reason it doesn't work for self-closing ?

@PerryvanderMeer
Copy link
Contributor

See #44413

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

Successfully merging this pull request may close these issues.

None yet

5 participants