Posts tagged with blade

Laravel Blade Helpers

liamhammett.com

Liam Hammett created a cool package to easily create Blade Helpers in Laravel.

I put together a package that attempts to help make these helper functions that little bit easier to define without the boilerplate of returning the string or having to consider what an expression may be when creating a Blade directive.

Read more [liamhammett.com]

Use custom html components in your Blade views

by Freek Van der Herten – 7 minute read

Today we launched our newest package called BladeX. In short this package provides you with an easy html like way to render custom html components in your Blade views. In this blogpost I'd like to introduce the package to you. A first example When building a server rendered app you're probably going…

Read more

Join thousands of developers

Every two weeks, I share practical tips, tutorials, and behind-the-scenes insights from maintaining 300+ open source packages.

No spam. Unsubscribe anytime. You can also follow me on X.

Introducing BladeX View Models

by Freek Van der Herten – 3 minute read

Earlier today we released BladeX, a package that allows you to use Blade components using a Vue inspired syntax. Read all about it in my previous blogpost. In the latest North Meets South podcast Jacob and Michael discussed BladeX and wondered if the package could be married with view models or…

Read more

Blade component aliases in Laravel 5.6

Laravel 5.6 will probably ship this wednesday. One of the cool new features is the ability to register Blade component aliases, which was PRed by my colleague Seb. On his blog Seb guides you through the new functionality.

Laravel 5.6 adds the ability to register alias directives for Blade components. Let's review some background information and examples.

https://sebastiandedeyne.com/posts/2018/blade-component-aliases-in-laravel-56

Read more

Theme-based views in Laravel using vendor namespaces

At Spatie, we're building a multi-tenant app. Seb figured out a great way to handle theme based views.

Laravel allows you register a view vendor namespace which points to a specific directory containing Blade files. This feature is intended for package development, but it's a perfect solution to our problem.

By registering a namespace with the current theme's location, we can drop all the dynamic parts of our view names when we're calling them.

https://sebastiandedeyne.com/posts/2017/theme-based-views-in-laravel-using-vendor-namespaces

Read more

Building a switch Blade directive

Inani El Houssain created a switch Blade directive. It's a good primer if you want to learn how to create Blade directives yourself.

One of the good points of Laravel’s framework is that it allows you to make your own components, macros and directives. so today we will make use of Laravel’s Custom Blade directives and make something good.

https://medium.com/@InaniT0/build-your-own-switch-statment-using-laravels-custom-blade-directives-218244e41a7c

Read more

A Blade directive to export PHP variables to JavaScript

by Freek Van der Herten – 1 minute read

Today we released our new package called laravel-blade-javascript. It provides you with a javascript Blade directive to export PHP variables to JavaScript. So it basically does the same as Jeffrey Way's popular PHP-Vars-To-Js-Transformer package but instead of exporting variables in the controller…

Read more

Custom conditionals with Laravel's Blade Directives

Matt Stauffer explains when and how you can leverage custom blade directives.

One of the greatest aspects of Laravel Blade is that it's incredibly easy to handle view partials and control logic. I find myself frequently extracting the contents of a loop out to a Blade partial and then passing just a bit of data into the partial.

But sometimes the repetitive code isn't the view itself, but the conditional logic I'm running.

https://mattstauffer.co/blog/custom-conditionals-with-laravels-blade-directives

Read more

Comparing Blade and Twig templates in Laravel

In my company, we use Twig instead of Blade for our Laravel projects. I know there are a lot of developers that also prefer Twig over Blade. So the question ‘Why choose Twig over Blade?’ often pops up. The reason is usually just a matter of preference, but in this post we’re going to compare the Blade and Twig templating engines side-by-side.

http://barryvdh.nl/laravel/twig/2015/08/22/comparing-blade-and-twig-templates-in-laravel/

If you want to try out Twig in a Laravel project, you can use this bridge package.

Read more