我正在使用Laravel 4.2並嘗試使用刀片。無法訪問刀片引擎以包含部分
所以,在/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>
在
/app/views/testView.blade.php
是
@secton('content')
<p>{{ 'Hello World from section...' }}</p>
@stop
{{'Hi every one'}}
<p>It doesn't work :(</p>
而我的控制器如下:
class HomeController extends BaseController {
protected $layout = 'layouts.test';
public function index()
{
$this->layout->content = View::make('testView');
}
}
但最後的輸出如下所示:
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>
我也嘗試另一種方式(不包括在控制器保護$佈局,但在testView.blade.php @extends),但結果是一樣的。我做錯了什麼?
@secton( '內容')=> @section( '內容')? – 2014-12-02 15:44:25
哈哈哈感謝兄弟......是的,就是這樣。 – Dusan 2014-12-02 15:46:40
在發佈到StackOverflow之前,我看了好幾次,但真的沒有看到它。 – Dusan 2014-12-02 15:48:40