2013-06-24 43 views
2

我遇到了我的刀片模板问题。出于某种原因,我将我的视图的内容打印了两次,一次是我期待的yield,另一次是延长的视图执行任何操作之前的时间。为什么我的刀片模板内容显示两次?

我的路线是:

Route::get('/', array('as' => 'home', function() { 
    return View::make('default'); 
})); 

默认视图(default.blade.php)是这样的:

@extends('test') 

@section('title') 
    Default 
@show 

@section('content') 
    <p>Content goes here<p> 
@show 

而且测试视图(test.blade.php)是这样的:

<h1>Anything above should be be there!</h1> 
<h3>@yield('title')</h3> 
@yield('content') 

这生成:

Default 
<p>Content goes here<p> 
<h1>Anything above should be be there!</h1> 
<h3>Default</h3> 
<p>Content goes here<p> 

回答

4

尝试

@extends('test') 

@section('title') 
    Default 
@stop 

@section('content') 
    <p>Content goes here<p> 
@stop 
+0

啊,我没赶上示区别,并停止。谢谢! – vikingsfan19

+0

小心解释'show'和'stop'之间的区别? – Julian

+2

如果您使用'@ show',Laravel会认为这是您的默认值,可以由另一个'@section('content')'覆盖。 –

1

不应该是这样的...... @stop代替@show

@extends('test') 

@section('title') 
Default 
@stop 

@section('content') 
<p>Content goes here<p> 
@stop