Skip to content

[5.8] Add @componentFirst Directive#28783

Merged
taylorotwell merged 1 commit intolaravel:5.8from
browner12:component-first
Jun 11, 2019
Merged

[5.8] Add @componentFirst Directive#28783
taylorotwell merged 1 commit intolaravel:5.8from
browner12:component-first

Conversation

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

2 participants