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

[5.6] Blade component aliases #22796

Merged
merged 1 commit into from
Jan 15, 2018
Merged

[5.6] Blade component aliases #22796

merged 1 commit into from
Jan 15, 2018

Conversation

sebastiandedeyne
Copy link
Contributor

This PR adds a component method to Blade for registering component aliases. Blade components are one of my favorite additions to Laravel, but the syntax can be quite verbose sometimes. This adds an easy way to create component directives, for components that you're going to use all over your app.

Blade::component('app.components.alert', 'alert');
@alert(['type' => 'danger'])
    @slot('title')
        Forbidden
    @endslot

    You are not allowed to access this resource!
@endalert

This PR also adds a shorter syntax, that assumes that you'll want to alias your component to the last part of the component path. This allows you to omit the second argument.

Blade::component('app.components.alert');

You lose explicitness though, so I could drop that from the PR if it's in the way.

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