Skip to content

[5.6] Blade component aliases#22796

Merged
taylorotwell merged 1 commit intolaravel:5.6from
sebastiandedeyne:blade-component-aliases
Jan 15, 2018
Merged

[5.6] Blade component aliases#22796
taylorotwell merged 1 commit intolaravel:5.6from
sebastiandedeyne:blade-component-aliases

Conversation

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