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

Conversation

Projects
None yet
2 participants
@browner12
Copy link
Contributor

commented Jun 10, 2019

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 `@componentFirst` directive
- 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

2 checks passed

continuous-integration/styleci/pr The analysis has passed
Details
continuous-integration/travis-ci/pr The Travis CI build passed
Details

@browner12 browner12 deleted the browner12:component-first branch Jun 11, 2019

browner12 added a commit to browner12/docs that referenced this pull request Jun 18, 2019

add `@componentFirst` documentation
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.

GuntherDebrauwer added a commit to GuntherDebrauwer/docs that referenced this pull request Jun 20, 2019

add `@componentFirst` documentation
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
You can’t perform that action at this time.