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

[8.x] Allow index.blade.php views for anonymous components #38847

Merged

Conversation

calebporzio
Copy link
Contributor

For a hypothetical "accordion" anonymous Blade component system (a component with sub-components), I would love to use the following syntax:

<x-accordion>
    <x-accordion.item>
        ...

This PR allows me to use index.blade.php as a default view for an anonymous component pointing to a folder.

Here would be the folder structure

  • components/accordion
    • index.blade.php
    • item.blade.php

This expands on the convention of index.html/php/js inside folders.

Without this addition, I have to use redundant wrapper names like: <x-accordion.accordion>, <x-accordion.group>, or have a file called accordion.blade.php at the same level as the accordion folder holding the sub-component views.

As far as breaking changes, because this addition is only run immediately before an error is thrown about not being able to find a view for a component, I don't see it causing any odd behavior for existing projects. I could have missed something though of course.

Thanks for your time and attention!

@taylorotwell taylorotwell merged commit 3d687d9 into laravel:8.x Sep 20, 2021
@Wulfheart
Copy link

I really like this approach and I’m really exited to use it in my projects.

@driesvints
Copy link
Member

@calebporzio great one 👍

@mnaderian
Copy link

This is gonna open the door for Laravel Components Market!

@brentarcane
Copy link

PSA: You may need to run php artisan view:clear for this to work 😃

@driesvints
Copy link
Member

driesvints commented Oct 12, 2021

@brentarcane it's a good idea to always do that when updating Laravel.

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.

6 participants