【发布时间】:2014-11-26 20:44:21
【问题描述】:
来自http://laravel.com/docs/4.2/templates:
(控制器)
class UserController extends BaseController {
/**
* The layout that should be used for responses.
*/
protected $layout = 'layouts.master';
/**
* Show the user profile.
*/
public function showProfile()
{
$this->layout->content = View::make('user.profile');
}
}
(模板)
@extends('layouts.master')
@section('sidebar')
<p>This is appended to the master sidebar.</p>
@stop
@section('content')
<p>This is my body content.</p>
@stop
为什么layouts.master 需要被调用两次? $this->layout 需要设置为 layouts.master 以及您需要将 layouts.master 传递给 @extends() 的事实似乎......多余且不必要。
【问题讨论】:
-
你不需要这样做:laravel.io/forum/… 见 'koomai' 的回复
标签: php laravel laravel-4 blade laravel-5