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

[7.x] Set component alias name #32346

Merged
merged 1 commit into from
Apr 13, 2020
Merged

[7.x] Set component alias name #32346

merged 1 commit into from
Apr 13, 2020

Conversation

driesvints
Copy link
Member

@driesvints driesvints commented Apr 12, 2020

I have a use case where I want to conditionally render the contents of a component based on its alias name. For example, when you have an Svg component and use <x:heroicon-o-bell/> which is aliased to the component as follows:

Blade::component(Svg::class, 'heroicon-o-bell');

This is much cleaner than having to do <x:svg name="heroicon-o-bell"/>. Adding the alias name to the Component class will open up many new use cases and possibilities for Blade components 🌟

Fyi: I picked $componentName rather than $name to not clash with component attributes using $name already.

@BSN4
Copy link
Contributor

BSN4 commented Apr 12, 2020

maybe

Blade::component(Svg::class, 'svg-{icon}');

?

@driesvints
Copy link
Member Author

@if4lcon I think you misunderstood what I meant.

@taylorotwell taylorotwell merged commit c2cdb44 into 7.x Apr 13, 2020
@driesvints driesvints deleted the component-names branch April 13, 2020 14:19
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.

3 participants