我一直在阅读Laravel 4文档,并且一直在制作演示应用程序来帮助学习。Laravel 4控制器模板/刀片 - 正确的方法?
我无法找到有关使用刀片和控制器进行视图模板化的大量文档。 哪一个是正确的方法还是归结为个人偏好?
E.g. 1个
控制器/ HomeController.php
protected $layout = 'layouts.main';
public function showWelcome()
{
$this->layout->title = "Page Title";
$this->layout->content = View::make('welcome');
}
查看/布局/ main.blade.php
<html>
<head>
<title>{{ $title }}</title>
</head>
<body>
{{ $content }}
</body>
</html>
查看/ welcome.blade.php
<p>Welcome.</p>
E.g. 2个
控制器/ HomeController.php
protected $layout = 'layouts.main';
public function showWelcome()
{
$this->layout->content = View::make('welcome');
}
查看/布局/ main.blade.php
<html>
<head>
<title>@yield('title')</title>
</head>
<body>
@yield('content')
</body>
</html>
查看/ welcome.blade.php
@section('title', 'Welcome')
@section('content')
// content
@stop
上述的最佳约定和/或优点是什么?
请纠正我,如果上面的例子或不正确的方式以及! – Mediabeastnz