Laravel: Template

  • Create New Template File : resources/views/layout/main.blade.php
<!-- the title is place to pass the variable from the controller-->
<head>
<title>@yield('title')</title>
</head>
/*
|--------------------------------------------------------------------------
| Fill out with HTML template
|--------------------------------------------------------------------------
*/

<!-- this for dynamic content-->
@yield('container')
  • Create view page: resources/views/index.blade.php
<!-- variable extend from template main.blade.php-->
@extends('layout/main');

<!-- pass variable to template -->
@section('title','Home pages example');

<!-- variable that more than one line and need to be passed to template -->
@section('container');
<div class='container'>
/*
|--------------------------------------------------------------------------
| Fill out with HTML template
|--------------------------------------------------------------------------
*/
</div>
@endsection

Leave a Reply

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