Blade Template Engine — Laravel 10 Discovery Training

In this chapter we will discover the part seen in the MVC structure. Laravel has a template engine that will allow us to generate HTML views more easily.

Blade views will be created in files with the extension .blade.php and we can display the variables using braces.

{{ $username }}

This method, compared to the use of simple <?= ?> automatically escapes HTML characters.

It is also possible to use conditions and loops using directives that will be prefixed with an @.

@if (count($records) === 1)
    I have one record!
@elseif (count($records) > 1)
    I have multiple records!
    I don't have any records!