Speed up development with full-stack environments for every branch.

Learn More

Introducting to the Blade template engine [PHP and Laravel]

1303 Runs 9460 Views 712 Copies


richardruiter 14

published 3 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'));
Please login/signup to get access to the terminal.

Your session has timed out.

Dismiss (the page may not function properly).