Skip to content

Scoped slots feature addition to Laravel's Blade templating engine

License

Notifications You must be signed in to change notification settings

konradkalemba/blade-components-scoped-slots

Folders and files

NameName
Last commit message
Last commit date

Latest commit

 

History

7 Commits
 
 
 
 
 
 
 
 
 
 

Repository files navigation

blade-components-scoped-slots

Latest Stable Version Total Downloads

Scoped slots feature addition to Laravel's Blade templating engine. The package adds two new Blade directives: @scopedslot and @endscopedslot. Inspired by Vue's scoped slots feature.

Installation

composer require konradkalemba/blade-components-scoped-slots

Usage example

index.blade.php

@component('components.list', ['objects' => $objects])
    @scopedslot('item', ($object))
    // It is also possible to pass outside variable to the scoped slot
    // by using the third parameter: @scopedslot('item', ($object), ($variable))
        <li>
            {{ $object->name }} 
            @if($object->isEditable)
                <a href="{{ route('objects.edit', $object->id) }}">{{ __('Edit') }}</a>
            @endif
        </li>
    @endscopedslot
@endcomponent

components/list.blade.php

<ul>
    @foreach($objects as $object)
        {{ $item($object) }}
    @endforeach
</ul>

License

License

About

Scoped slots feature addition to Laravel's Blade templating engine

Topics

Resources

License

Stars

Watchers

Forks

Packages

No packages published

Languages