Reputation: 417
Recently began learning laravel4 and i am experimenting with blade templates. For some reason these was working but all of a sudden they have stopped working and when i go to view the site with said template on it just shows the @yield directive and not displaying the section its meant to be .
https://i.sstatic.net/ehMBK.png <-- screenshot of source when viewed in browser
This is all the code i am using currently this is dead basic stuff
app/routes.php
//set base route
Route::get('/', 'HomeController@index');
app/controllers/HomeController
<?php
class HomeController extends BaseController {
protected $layout = 'base';
public function index()
{
$data = array(
'heading' => 'Hello Laravel (from Home)',
'body' => 'This is awesome, from the HomeController'
);
$this->layout->content = View::make('test', $data);
}
}
app/views/base.php (html layout template)
<!doctype html>
<html>
<head>
<title>Something</title>
</head>
<body>
<div class="container">
@yield('content')
</div>
</body>
</html>
app/views/test.blade.php
@section('content')
<h1>{{ $heading }}</h1>
<p>{{ $body }}</p>
@stop
Thats pretty much it i have no idea why its not showing up when i view the site. This did work and then for some reason stopped and i have no idea why. I have even tried a fresh install of laravel with the same results.
Upvotes: 0
Views: 1651
Reputation: 2182
You need to add @extends to your test.blade.php and rename your base.php to base.blade.php.
@extends('base')
Upvotes: 1