저는 Laravel 4 문서를 읽고 학습을 돕기 위해 데모 응용 프로그램을 만들고 있습니다.Laravel 4 컨트롤러 템플릿/블레이드 - 올바른 방법?
블레이드 및 컨트롤러가 포함 된 뷰 템플릿에 대한 많은 문서를 찾을 수 없습니다. 올바른 방법은 무엇입니까? 아니면 개인 취향에 달려 있습니까?
예 : 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>
예. 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