[英]Can't reach Blade engine to include section
I'm using Laravel 4.2 and trying to play with Blade. 我正在使用Laravel 4.2并尝试与Blade一起玩。
So, in /app/views/layouts/test.blade.php I have 因此,在/app/views/layouts/test.blade.php中,我有
<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 在/app/views/testView.blade.php中是
@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. 我还尝试了另一种方式(在控制器中没有受保护的$ layout,但在testView.blade.php中具有@extends),但是结果是相同的。 What I'm doing wrong?
我做错了什么?
You didnt call the test.blade.php properly. 您没有正确调用test.blade.php。 Your /app/views/testView.blade.php should look like this
您的/app/views/testView.blade.php应该看起来像这样
@extends('layouts/test)
@secton('content')
<p>{{ 'Hello World from section...' }}</p>
@stop
{{'Hi every one'}}
<p>It now works :)</p>
It should work now 现在应该可以工作了
声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.