PHP code example of crhayes / blade-partials

1. Go to this page and download the library: Download crhayes/blade-partials library. Choose the download type require.

2. Extract the ZIP file and open the index.php.

3. Add this code to the index.php.
    
        
<?php
require_once('vendor/autoload.php');

/* Start to develop here. Best regards https://php-download.com/ */

    

crhayes / blade-partials example snippets


'providers' => array(
    //'Illuminate\View\ViewServiceProvider',
    ...
    'Crhayes\BladePartials\ViewServiceProvider',
)

@partial('partials.panel')
    @block('title', 'This is the panel title')

    @block('body')
        This is the panel body.
    @endblock
@endpartial

// index.blade.php
@extends('layouts.master')
 
@section('content')
    @partial('partials.panel')
        @block('title', 'This is the panel title')
 
        @block('body')
            This is the panel body.
        @endblock
    @endpartial
    
    @partial('partials.panel')
        @block('title', 'This is a second panel title')
 
        @block('body')
            And we will have different content in this body.
        @endblock
    @endpartial
@stop
 
// /partials/panel.blade.php
<div class="panel">
    <div class="panel-heading">
        <h3 class="panel-title">@render('title')</h3>
    </div>
    <div class="panel-body">
        @render('body')
    </div>
</div> 

// index.blade.php
@extends('layouts.master')

@section('content')
    @partial('partials.danger-panel')
        @block('title', 'This is the panel title')
    
        @block('body')
            This is the panel body.
        @endblock
    @endpartial
@stop

// partials/danger-panel.blade.php
@partial('partials.panel')
    @block('type', 'danger')

    @block('title')
    	Danger! @render('title')
    @endblock
@endpartial

// partials/panel.blade.php
<div class="panel panel-@render('type', 'default')">
    <div class="panel-heading">
        <h3 class="panel-title">@render('title')</h3>
    </div>
    <div class="panel-body">
        @render('body')
    </div>
</div>