Laravel Classroom image

To post your Question Join Classroom
Lesson Topics's No:-  |1 | 2 | 3|Last
Lessons:-Blade Templates

Blade Templates
Laravel’s Blade templating engine will allow you to use very neat looking syntax to embed PHP
code within your views. It also includes a number of short-cuts that allow a cleaner use of
existing Laravel features. Blade’s templates are cached by default, which makes them extremely
As always, let’s jump right in.
13.1 The Basics
To enable Blade templating, simply name your views with the extension .blade.php instead of
.php, it’s as simple as that!
When using view files with PHP frameworks, you will often find yourself using this.
1 <?php echo $val; ?>
By enabling PHP short tags we can tidy this up a little.
1 <?=$val?>
However there is still room for improvement. Let’s have a look at how Blade would handle the
same echo statement.
1 {{ $val }}
Neat! The spacing between the brackets is optional, but I think it looks better with it there. You
see the contents of the double curly brackets is evaluated and echoed out. You can use any PHP
you want in there, for example..
1 {{ 5 * time() }}
This snippet will work just as well. You see all Blade is doing, is converting {{ 5 * time() }} to
<?php echo 5 * time(); ?>. Be sure to consider this if you run into any problems with blade!



Skills    Laravel

Qualifications :-
Location :-,,,

  Students (0)