BLADE
TEMPLATE:
Blade
is the simple, yet powerful templating engine that is included with Laravel.
Unlike some PHP templating engines, Blade does not restrict you from using
plain PHP code in your templates. In fact, all Blade templates are compiled
into plain PHP code and cached until they are modified, meaning Blade adds
essentially zero overhead to your application. Blade template files use
the .blade.php
file extension
and are typically stored in the resources/views
directory.
Viewing
different webpages using a single layout by creating different blade files:
Step 1: First we have
to create a layout of a webpage.
(a)
In the above screenshot that I marked in green. That is the URI we
should give in the route file (web.php) at the end to view different blade
files.
(b) And then footer
(c)
Now I am creating a layout for our
webpage
In the above screenshot I had included two directives
(a)
Include:
Include directive @include is used for showing
static content in master layout. I had include my header and footer
blade file in this layout.
(b) Section:
The @section directive, as the name
implies, defines a section of content. Here I had divided
a section for the body. So that I can change the body of my layout.
Output:
Step 2: Now I am going to create section of my body tag by using
class “register” that I had mentioned in my section directives.
And also I use
@extend directives. @extends lets you "extend" a
template, which defines its own sections
(a)
(b)
Creating body of register page using section
directives by mentioning the class “register”
(c)
Creating body of login page using section
directives by mentioning the class “register”
Step 3: At last we have to give route for these blade files in
web.php file.
I had given the URI
to view each blade file that I marked in green.
Output:
At last our output by
clicking each link in the layout page will be
(a)
Home page:
(b) Register page:
(c)
THANK YOU
Comments