Creating a view using Blade
PHP has many templating libraries available and Laravel's Blade is one of the best. This recipe will show an easily extendable way to get up-and-running with Blade templates, and quickly.
Getting ready
For this recipe, we need a standard Laravel installation.
How to do it...
To complete this recipe, follow these steps:
In the
routes.php
file, create new routes for our pages as follows:Route::get('blade-home', function() { return View::make('blade.home'); }); Route::get('blade-second', function() { return View::make('blade.second'); });
In the
views
directory, create a new folder namedlayout
.In the
views/layout
directory, create a file namedindex.blade.php
and add the following code to it:<!doctype html> <html lang="en"> <head> <meta charset="utf-8"> <title>My Site</title> </head> <body> <h1> @section('page_title') Welcome to @show </h1> @yield('content...