Laravel package providing additional Blade extensions.
Implemented and tested directives:
- @foreach (with $loop data, like twig)
- @break
- @continue
- @set
- @debug
@foreach($stuff as $key => $val)
$loop->index; // int, zero based
$loop->index1; // int, starts at 1
$loop->revindex; // int
$loop->revindex1; // int
$loop->first; // bool
$loop->last; // bool
$loop->even; // bool
$loop->odd; // bool
$loop->length; // int
@break
@continue
@endforeach
@set('newvar', 'value')
{{ $newvar }}
@debug($somearr)
- PHP > 5.3
- Laravel > 4.0
- (optional) raveren/kint > 0.9.1
Add to composer.json
"radic/blade-extensions": "1.*"
Add to app/config/app.php
to register the service provider
'Radic\BladeExtensions\BladeExtensionsServiceProvider'
Publish the configuration file
php artisan config:publish radic/blade-extensions
return array(
/*
* Blacklisting of directives. These directives will not be extended. Example:
*
* 'blacklist' => array('foreach', 'set', 'debug')
*/
'blacklist' => array(),
/*
* Prepend and append the debug output.
*/
'debug' => array(
/*
* Prepend any code in front of our variable name
*
* The default config also checks if Kint is installed for sweet debug output.
* Check https://github.com/raveren/kint.
*
*/
'prepend' => "<h1>DEBUG OUTPUT:</h1><pre><code><?php " . (class_exists('Kint') ? "Kint::dump(" : "var_dump("),
/*
* Append any code behind our variable name
*/
'append' => ") ?></code></pre>"
)
);
Copyright 2014 Robin Radic - MIT Licensed