Appstract Laravel Blade Directives

Add extra directives to Laravel Blade Templating Engine using this package.

Appstract Laravel Blade Directives

Spread the word! Share with your fellow developers.

There are tons of packages available for Laravel in the community for extending the functionality of the Laravel framework.

You should check appstract/laravel-blade-directives package, which will add some handy blade directives to your Laravel project.

You can install this package by requiring it through Composer.

composer require appstract/laravel-blade-directives

Here are some of the helpful blade directives which come with this package.

Font Awesome Icon

Quickly output a font-awesome icon using below directive.

@fa('trash')

Route Check

You can check if the current route matches using below directive.

    @routeis('admin.dashboard')
        // Do something awesome here
    @endrouteis

Alternative to var_dump() and dd()

Normally Laravel blade doesn’t have a blade directive to dump the variables within your views unless you do something like below.

    @php
        var_dump($variable);
    @endphp

This package provides a shortcut to about method.

@dump($variable)
    @dd($variable)

Script Element

You can use the below directive to open a script element within your view with or without a js path.

    @script
        console.log('Hello Laravel')
    @endscript

    Or

    @script('js/app.js')

Style Element

Create a <style/> element or <link/> element with a css path.

    @style
        body {font-size: 16px;}
    @endstyle
    Or
    @style('css/custom.css')

Inline CSS or JS

Display CSS or js inline within your view using below directive

    @inline('css/custom.css')

Wrap Up

To learn more about the features of this package head over to Github Repository of this package where you will be able to explore all instructions and documentation of this package.

Leave a Reply

Your email address will not be published. Required fields are marked *

*

*
*

This site uses Akismet to reduce spam. Learn how your comment data is processed.