I'm using Laravel 4.2 and trying to play with Blade.
So, in /app/views/layouts/test.blade.php I have
<html>
<head>
<title>TEST LAYOUT</title>
</head>
<body>
<p>{{ date('d/m') }}</p>
<p>
@yield('content')
</p>
</body>
</html>
in /app/views/testView.blade.php is
@secton('content')
<p>{{ 'Hello World from section...' }}</p>
@stop
{{'Hi every one'}}
<p>It doesn't work :(</p>
And my controller is as follows:
class HomeController extends BaseController {
protected $layout = 'layouts.test';
public function index()
{
$this->layout->content = View::make('testView');
}
}
But the final output looks like this:
Hi every one
<p>It doesn't work :(</p>
<html>
<head>
<title>TEST LAYOUT</title>
</head>
<body>
<p>02/12</p>
<p>
</p>
</body>
</html>
I also tried another way (without protected $layout in controller but with @extends in testView.blade.php) but the result is the same. What I'm doing wrong?
You didnt call the test.blade.php properly. Your /app/views/testView.blade.php should look like this
@extends('layouts/test)
@secton('content')
<p>{{ 'Hello World from section...' }}</p>
@stop
{{'Hi every one'}}
<p>It now works :)</p>
It should work now
The technical post webpages of this site follow the CC BY-SA 4.0 protocol. If you need to reprint, please indicate the site URL or the original address.Any question please contact:yoyou2525@163.com.