2017 © Pedro Peláez
 

library laravel-blade-render-flow

Render flow extension for Laravel Blade

image

pustato/laravel-blade-render-flow

Render flow extension for Laravel Blade

  • Tuesday, April 11, 2017
  • by pustato
  • Repository
  • 1 Watchers
  • 0 Stars
  • 356 Installations
  • PHP
  • 0 Dependents
  • 0 Suggesters
  • 0 Forks
  • 0 Open issues
  • 2 Versions
  • 13 % Grown

The README.md

Render flow extension for Laravel Blade

This package adds a several blade directives that lets you reuse a parts of templates., (*1)

Install

Require this package with composer:, (*2)

composer require pustato/laravel-blade-render-flow

Add the ServiceProvider to the providers section in your config/app.php:, (*3)

Pustato\LaravelBladeRenderFlow\ServiceProvider::class,

Usage

@capture

Lets you render a section of template once and reuse it later., (*4)

  • @capture(block_name) starts capturing block of template with name block_name.
  • @endcapture ends block.
  • @flushcapture ends block and instantly renders it.
  • @flush(block_name) render stored block.
  • @clearcapture([block_name]) if block_name is specified, forgets block with this name, else - forgets all stored blocks.

Example:, (*5)

@php
    $src = 'http://placehold.it/100x100';
    $title = 'Placeholder image';
@endphp
@capture(placeholder)
<img src="{{ $src }}" title="{{ $title }}" alt="{{ $titel }}"/>
@endcapture



@flush('placeholder')
@flush('placeholder')
@flush('placeholder')
@clearcapture('placeholder')

Will be rendered to:, (*6)

<div>
    <img src="http://placehold.it/100x100" title="Placeholder image" alt="Placeholder image"/>
</div>
<div>
    <img src="http://placehold.it/100x100" title="Placeholder image" alt="Placeholder image"/>
</div>
<div>
    <img src="http://placehold.it/100x100" title="Placeholder image" alt="Placeholder image"/>
</div>

@template

Lets you specify a section of sub template to store it in a memory., (*7)

  • @templage(name) starts sub template with name.
  • @endtemplate ends sub template.
  • @render(name[, params]) render a sub template with specified params (works like @include).

Example:, (*8)

@template('img')
<img src="{{ $src or 'http://placehold.it/100x100' }}" alt="{{ $title or 'Image alt' }}" title="{{ $title or 'Image title' }}"/>
@endtemplate



@render('img')
@render('img', ['src' => 'http://placehold.it/350x350', 'title' => 'Large placeholder'])
@render('img', ['src' => 'http://placehold.it/32x32', 'title' => 'Tiny placeholder'])

Result:, (*9)

<div>
    <img src="http://placehold.it/100x100" alt="Image alt" title="Image title">
</div>
<div>
    <img src="http://placehold.it/350x350" alt="Large placeholder" title="Large placeholder">
</div>
<div>
    <img src="http://placehold.it/32x32" alt="Tiny placeholder" title="Tiny placeholder">
</div>

The Versions

11/04 2017

dev-master

9999999-dev

Render flow extension for Laravel Blade

  Sources   Download

MIT

The Requires

 

The Development Requires

by Alexander Atamanov

11/04 2017

1.0.0

1.0.0.0

Render flow extension for Laravel Blade

  Sources   Download

MIT

The Requires

 

The Development Requires

by Alexander Atamanov