Laravel is a robust PHP web framework for building dynamic web applications. The powerful templating engine blade is provided by Laravel.

With Laravel 9, released in January 2022, comes a new version of Blade, bringing with it a number of new features and improvements.

One of the most significant changes in Blade templating with Laravel 9 is the introduction of “raw” Blade directives. Raw directives allow you to print the contents of a Blade template variable without HTML encoding it first. This can be useful when you want to print the raw value of a variable, without any HTML escaping.

To use a raw directive, simply prefix the variable name with an @ sign. For example, to print the contents of a variable $foo without HTML encoding, you would use the following code: @raw($foo)

Another significant change in Blade templating with Laravel 9 is the way in which template inheritance works. In previous versions of Laravel, all child templates had to extend the layout defined in the parent template.

With Laravel 9, you can now extend any template, regardless of its position in the inheritance hierarchy. This change makes it much easier to reuse template fragments across your application. For example, you may have a number of different “page” templates, each of which extends a common “layout” template.

With Laravel 9, you can now move template fragments around without updating the extended declarations in all of your templates.

As well as these new features, Laravel 9 also brings with it a number of improvements to existing Blade features.

For example, the @include directive now supports passing an array of data to the included template, making it easier to reuse template fragments that require data from the current context.

If you’re building web applications with Laravel, then Blade templating is a powerful tool you should use. With the new features and improvements in Laravel 9, creating beautiful and dynamic web applications has never been easier.

By Navid Anjum

Full-stack web developer and founder of Laravelaura. He makes his tutorials as simple as humanly possible and focuses on getting the students to the point where they can build projects independently.

Leave a Reply

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