Introducting to the Blade template engine [PHP and Laravel]

993 Runs 7357 Views 568 Copies


richardruiter 14

published 2 years ago


 * Blade is the default template engine of Laravel and it is simple yet it
 * has all the powertools you need.
 * This example will respond to the default route with a introduction page.
 * The route will define some data and pass it to the 'View'.
 * The view will create the page based on the introduction.blade.php template.
 * When the template is rendered it has done 3 things:
 * 1. Extend the basic layout from layout.blade.php
 * 2. Generated the title section with the given title from the route
 * 3. Generated the rows given by the route using table.blade.php

Route::get('/', function()
  // give the page a title
  $title = 'The amazing people list';
  // generate a small data list for looping
  $rows = array(
    array('name' => 'John Doe', 'age' => 21), 
    array('name' => 'Hill Billy', 'age' => 83),
  return View::make('introduction', compact('title', 'rows'));


Your session has timed out.

Dismiss (the page may not function properly).