what is template in laravel

 

 

 

 

 

 

 

 

Laravel’s Blade provides a way to build templates that can benefit from inheritance. Many peoplefind this confusing, yet it’s a really neat feature. I’m going to try and simplify it as best as I can andhopefully you will soon find the art of creating templates to be a pleasurable experience;

what is template in laravel and how to use it .

 

<!– app/views/layouts/base.blade.php –>

<!doctype html>
<html lang=”en”>
<head>
<meta charset=”UTF-8″>
<title></title>
@section(‘head’)
<link rel=”stylesheet” href=”style.css” />
@show
</head>
<body>
@yield(‘body’)
</body>
</html>
Here above we have created two sections :
1-
@section (‘head’)
@show
2-
@yield(‘body’)
This one is very similar to the ‘yield’ section, except that you can provide some default content. In
the above example, the content between the @section and @show tags will be shown unless a child
template chooses to override it.
Now i am giving an example of child template:

<!– app/views/home.blade.php –>

@extends(‘layouts.base’)

@section(‘body’)
<h1>Hurray!</h1>
<p>We have a template!</p>
@stop

We are extending layout from base.php
@section(‘body’)
<!– we are getting body response from base layout and ending it –>
<!–and ending it with @stop–>
Right, let’s walk through this. First we have the ‘extends’ blade function:
@extends(‘layouts.base’)

 

<!– app/views/home.blade.php –>

@extends(‘layouts.base’)

@section(‘head’)
<link rel=”stylesheet” href=”another.css” />
@stop

@section(‘body’)
<h1>Hurray!</h1>
<p>We have a template!</p>
@stop

for more go to laravel