Laravel 5.4 Blade introduced the concept of components and slots - but I donβt see what they add to the traditional @include. As I understand it, with components / slots you do:
In the template component-tpl.blade.php:
<div class='container'> <h1>{{$slot1}}</h1> <h2>{{$slot2}}</h2> </div>
Using the slots in the page template, do the following:
@component('component-tpl') @slot('slot1') The content of Slot 1 @endslot @slot('slot2') The content of Slot 2 @endslot @endcomponent
What functionality does the older provide:
@include('component-tpl',['slot1'=>'The content of Slot 1', 'slot2'=>"The content of Slot 2"])
using the same Blade.php template 'component-tpl.blade.php'
What am I missing? Thanks for any ideas.
Chris
Chrisny
source share