Skip to content
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

[9.x] Support kebab case for slot name shortcut #42574

Merged

Conversation

Waghabond
Copy link
Contributor

@Waghabond Waghabond commented May 30, 2022

This is a revision of #42536 as per @taylorotwell's request

The inline slot name shortcut was added in laravel 9 but it does not comply with the blade component kebab case naming convention.
This PR will make the feature fit intuitively with the blade component naming conventions.
Any kebab-cased slot names will be converted to camelCase so they can be used like so:

<!-- /resources/views/components/my-layout.blade.php -->
<html lang="en">
    <body>
        {{ $mySlot }}
    </body>
</html>

<!-- /resources/views/components/child.blade.php -->
<x-my-layout>
    <x-slot:my-slot>
        <div>My super cool content</div>
    </x-slot:my-slot>
</x-my-layout>

Previously this would have to be done like this:

<!-- /resources/views/components/child.blade.php -->
<x-my-layout>
    <x-slot:mySlot>
        <div>My super cool content</div>
    </x-slot:mySlot>
</x-my-layout>

Not bad, but it doesnt fit conventions and a multiword slot-name example isn't provided in the documentation.

Breaking Changes?

There are no breaking changes, slot names provided in camelCase or in snake_case will continue work the same.

The inline slot name shortcut was added in laravel 9 but it does not comply with the blade component kebab case naming convention (for when the slot name has more than 1 word). This edit will will make the feature fit intuitively with the blade component naming conventions.
A new capture group was added in order to support kebab case so the check for the existence of the dynamic component should be increased by 1
the pattern should have been a non capturing group instead of incrementing the index for matches.
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.

2 participants