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.8] Add @componentFirst Directive #28783

Merged
merged 1 commit into from Jun 11, 2019
Merged

[5.8] Add @componentFirst Directive #28783

merged 1 commit into from Jun 11, 2019

Conversation

browner12
Copy link
Contributor

The @component and @include Blade directives perform the same function with 2 distinctions.

  • @components allow you to pass in data via @slots.
  • @components only access variables passed to them, while @includes access all variables currently defined.

Even though these directives are so similar, @include gets some additional variations that are very useful.

  • @includeWhen
  • @includeIf
  • @includeFirst

Ideally, both the components and includes would maintain parity between these variations. This PR starts towards that goal by adding a @componentFirst directive.

<div>
    @componentFirst(['missing/file', 'found/file'])
        @slot('title', 'Test Component')
    @endcomponent
</div>

- add the compilation
- add the `startComponentFirst` method, which uses the View Factory to find the first view given that actually exists.
- add a test for the compilation.
@taylorotwell taylorotwell merged commit 9b7520a into laravel:5.8 Jun 11, 2019
@browner12 browner12 deleted the component-first branch June 11, 2019 13:47
browner12 added a commit to browner12/docs that referenced this pull request Jun 18, 2019
for laravel/framework#28783

I was going to hold off until I had PR'ed `componentWhen` and `componentIf`, but those are proving to be a little more difficult, so getting these docs in now.
gdebrauwer pushed a commit to gdebrauwer/docs that referenced this pull request Jun 20, 2019
for laravel/framework#28783

I was going to hold off until I had PR'ed `componentWhen` and `componentIf`, but those are proving to be a little more difficult, so getting these docs in now.
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.

None yet

2 participants