我主要布局模板/views/web/main_lo.blade.php
作为Laravel刀模板差异
<html>
<head>
<meta charset="UTF-8">
<title>{{$title or 'Default Title'}}</title>
</head>
<body>
<div class="section-1-outer">
@section('section-1')
<div class="section-1-parent">parent section 1</div>
@show
</div>
<div class="section-2-outer">
@section('section-2')
<div class="section-2-parent">parent section 2</div>
@show
</div>
<div class="section-3-outer">
@section('section-3')
<div class="section-3-parent">parent section 3</div>
@show
</div>
<div>
@yield('content')
</div>
</body>
</html>
和部分模板:
@extends('web.main_lo')
@section('section-1')
@parent
<div class='section-1-child'>
<p>Appended to parent</p>
</div>
@stop
@section('section-2')
<div class='section-2-child'>
<p>Replace parent</p>
</div>
@stop
@section('section-3')
<div class='section-3-child'>
<p>Replace parent</p>
</div>
@overwrite
现在,这里部分布局延伸main_lo,这里第一节-1这是相当清楚该子部分将包含父节1,并且父节中的内容也将被打印。
现在我的困惑是第二节和第三节的实现有什么区别,因为它们都替换父节的内容,并且只打印子节中的内容。我的意思是需要这个额外@overwrite
标签时documentation明确指出
“请注意,观点延伸刀片布局简单地从布局覆盖部分 。”
,然后有使用@overwrite
这也是用于替换父节的内容重写第。
好问题。一些指导在这里:http://laravel-recipes.com/recipes/244 –