How do I pass a variable to the layout using Laravel' Blade templating? How do I pass a variable to the layout using Laravel' Blade templating? laravel laravel

How do I pass a variable to the layout using Laravel' Blade templating?


If you're using @extends in your content layout you can use this:

@extends('master', ['title' => $title])


For future Google'rs that use Laravel 5, you can now also use it with includes,

@include('views.otherView', ['variable' => 1])


I was able to solve that problem by adding this to my controller method:

    $title = 'My Title Here';    View::share('title', $title);

$this->layout->title = 'Home page'; did not work either.