A collection of nice Laravel Blade directives
A collection of nice Laravel Blade directives
A collection of nice Laravel Blade directives.
You can install the package via composer:
composer require appstract/laravel-blade-directivesOnly show when $variable isset and true.
@istrue($variable)
This will be echoed
@endistrueOr when you would like to quickly echo
@istrue($variable, 'This will be echoed')Same as @istrue but checks for isset and false.
@isfalse($variable)
This will be echoed
@endisfalseOnly show when $variable is null.
@isnull($variable)
This will be echoed
@endisnullSame as @isnull but one shows when $variable is not null.
@isnotnull($variable)
This will be echoed
@endisnotnull@dump($var)
@dd($var)Create a HTML element to your Laravel-Mix css or js.
@mix('/css/app.css')
@mix('/js/app.js')Output:
Create a element or element with a css path.
@style
body { background: black }
@endstyle
@style('/css/app.css')Create a `
@endpushonce
Include pushes with standard `@stack` directive:
```blade
@stack('js')Checks if the current route name is equal to the given parameter. You can use a wildcard like blog.post.*.
@routeis('webshop.checkout')
Do something only on the checkout
@endrouteisChecks if the current route name is not equal to the given parameter. You can use a wildcard like blog.post.*
@routeisnot('webshop.checkout')
Do something only if this is not the checkout
@endrouteisnotChecks if the first parameter is an instance of the second parameter.
@instanceof($user, 'App\User')
User is an instance of App\User
@endinstanceofChecks if the parameter is of a certain type.
@typeof($text, 'string')
Text is a string
@endtypeofRepeat something a specified amount of times.
@repeat(3)
Iteration #{{ $iteration }}
@endrepeatQuickly output an icon with Font Awesome, Material Design Icons or Glyphicon.
@fa('address-book', 'optional-extra-class')
// for Font Awesome 5 (solid, regular, light, brand, duotone):
@fas('address-book', 'optional-extra-class')
@far('address-book', 'optional-extra-class')
@fal('address-book', 'optional-extra-class')
@fab('address-book', 'optional-extra-class')
@fad('address-book', 'optional-extra-class')
// for Material Design Icons
@mdi('account', 'optional-extra-class')
// for Glyphicons
@glyph('glass', 'optional-extra-class')Output data-attributes from an array.
@data(['testing' => 123])Quickly output for classical $errors->has('input_name') to determine if any error messages exist for a given field.
@haserror('input_name')
This input has an error
@endhaserrorOutput number of entries.
@count([1,2,3])Replaces \n into .
@nl2br('foo\n bar\n baz\n')Output formatted string (uses Laravel Helpers).
@snake('fooBar')
// output: 'foo_bar'
@kebab('fooBar')
// output: 'foo-bar'
@camel('foo bar')
// output: 'fooBar'composer testContributions are welcome, thanks to y'all :)
Appstract is a small team from The Netherlands. We create (open source) tools for Web Developers and write about related subjects on Medium. You can follow us on Twitter, buy us a beer or support us on Patreon.
The MIT License (MIT). Please see License File for more information.
No open issues yet, or sync has not completed.