Allow to use Angular transclude features within Blade templates.

v1.1.0 2017-08-30 16:43 UTC

This package is auto-updated.

Last update: 2020-07-06 00:00:04 UTC


Build Status Coverage Status

This package allow to use transclusion from Blade template engines. It's very useful when you want to handle views as component. It's inspired by the Angular transclude logic.


Latest Stable Version Total Downloads

This project can be installed using Composer. Add the following to your composer.json:

    "require": {
        "chstudio/laravel-transclude": "~2.0"

or run this command:

composer require chstudio/laravel-transclude

After updating composer, add the ServiceProvider to the providers array in config/app.php.

Laravel 5.5+

This library is compatible with the package auto-discovery feature so you have nothing to do... If you prefer adding yourself your providers, please follow the official documentation guidelines.

Laravel <5.5:

Add this in the providers section of the config/app.php file :


Then you can use the new blade directives in your views !


This package register three new Blade directives :

  • @transclude / @endtransclude to write inside a transcluded block,
  • @transcluded to declare a space where the transclusion will be written.

For example, take the Bootstrap form elements, they are all using the same global structure. Then in that structure there are different html blocks depending on the form element.

Create template files


<div class="form-group">
    <label for="{{ $name }}" class="control-label">{{$label}}</label>



    @foreach($options as $option)
    <div class="radio">
            <input name="{{$name}}" type="radio" {{$option['value']==$selected?' checked':''}} value="{{$option['value']}}" />

Use the new blocks

Then after writing this 3 files, you can add an element using the @include directive :

    @include('radio', [
        'options' => [
            ['value' => '1', 'label' => 'Option 1']
        'selected' => '1',
        'label' => 'My radio button'
        'name' => 'my-radio'

This code will generate a full radio element with a combination of input-group and radio templates :

    <div class="form-group">
        <label for="my-radio" class="control-label">My radio button</label>

        <div class="radio">
                <input name="my-radio" type="radio" checked value="1" />
                Option 1


We welcome everyone to contribute to this project. Below are some of the things that you can do to contribute.