Appstract Laravel Blade Directives – Laravel News

With no shortage of excellent blade extensions circulating in the community, you should also check out the appstract/laravel-blade-directives package.

Whether you end up installing the package or copying a few that you like to your project, here are some notable directives from the project:

Quickly output a font-awesome icon:


Check if the current route name matches:

    Do something only on the checkout

Only show when $variable isset and true.

   This will be echoed

Or you can do it inline:

@istrue($variable, 'This will be echoed')

@dump and @dd:


Load the contents of a CSS or js file inline in your view:


Create a element with or without a js path:

    alert('hello world')


Create a element or element with a css path:

    body { background: black }


Same as @push but will include content one time only. Useful for repeatable blocks following the syntax “stack-name:group-name”:



What’s Next?

To learn more about this package check out the GitHub Repository which includes all the instructions and everything you’ll need to get started. We’ve also covered Appstract’s Laravel OPCache package, which you should check out as well.

The framework itself has introduced some new convenient Blade features recently. In Laravel 5.5 LTS, the @auth and @guest directives were added. Another nice feature added to 5.5 is adding conditionals with Blade::if(). In 5.5.3, the @json directive was added to make outputting JSON objects in JavaScript easier.

★ READ ALSO ★  Create a Mock REST API in Seconds for Prototyping your Frontend

Source link

Leave a Reply

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