Saritasa custom blade directives

1.0.4 2018-01-17 16:17 UTC

This package is auto-updated.

Last update: 2020-07-21 14:31:47 UTC


Build Status Release PHPv Downloads

Custom Blade directives for Laravel Applications.


Laravel 5.x

Install the saritasa/blade-directives package:

$ composer require saritasa/blade-directives

If you use Laravel 5.4 or less, or 5.5+ with package discovery disabled, add the BladeDirectivesServiceProvider service provider config/app.php:

'providers' => array(
    // ...

Available directives


Output word 'active' if URL, requested by user, matches provided route name


<li class="@activeIfRoute('user.settings')">
    <a href="{{ route('user.settings') }}">Settings</a>


Output word 'selected' if passed expression evaluates to true


    @foreach($users as $user)
        <option value='{{ $user->id }}' @selectedIf($user->id == $currentUserId)>{{ $user->name }}</option>


  1. Create fork, checkout it
  2. Develop locally as usual. Code must follow PSR-1, PSR-2 - run PHP_CodeSniffer to ensure, that code follows style guides
  3. Update to describe new or changed functionality
  4. Add changes description to file. Use Semantic Versioning convention to determine next version number.
  5. When ready, create pull request

Make shortcuts

If you have GNU Make installed, you can use following shortcuts:

  • make cs (instead of php vendor/bin/phpcs) - run static code analysis with PHP_CodeSniffer to check code style
  • make csfix (instead of php vendor/bin/phpcbf) - fix code style violations with PHP_CodeSniffer automatically, where possible (ex. PSR-2 code formatting violations)
  • make install - instead of composer install
  • make all or just make without parameters - invokes described above install, cs tasks sequentially - project will be assembled and checked with linter with one single command