Skip to content

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

Merged
taylorotwell merged 6 commits into
laravel:9.xfrom
Waghabond:inline-slot-name-kebab-case-support
May 31, 2022
Merged

[9.x] Support kebab case for slot name shortcut #42574
taylorotwell merged 6 commits into
laravel:9.xfrom
Waghabond:inline-slot-name-kebab-case-support

Conversation

@Waghabond
Copy link
Copy Markdown
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.

Waghabond added 6 commits May 27, 2022 06:08
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