Laravel 5.4+ allows for components of the following structure:
<div class="alert alert-{{ $type }}">
<div class="alert-title">{{ $title }}</div>
{{ $slot }}
</div>
Which are called like:
@component('alert', ['type' => 'danger'])
@slot('title')
oh no
@endslot
Foo
@endcomponent
Is there a shorthand or blade marker to set default values for the variables passed in?
For example, in the above, if I don't pass in "type" I get a undefined variable
error. I could do something like:
<div class="alert alert-{{ isset($type) ? $type : 'default' }}">
But the above feels verbose, especially if the variable is used in multiple spots.