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

2 回答 2

4

尝试

@extends('test')

@section('title')
    Default
@stop

@section('content')
    <p>Content goes here<p>
@stop
于 2013-06-24T20:07:25.793 回答
1

这不应该是……@stop而不是@show

@extends('test')

@section('title')
Default
@stop

@section('content')
<p>Content goes here<p>
@stop
于 2013-06-24T20:08:03.900 回答