2016-02-19 53 views
1

我有一个样品视图:刀片不支持嵌套产量

文件:hello.blade.php

//includes the basic html enclosed tags 
<p>Hello world<p> 
@yield('content') 

文件:tester.blade.php

@extends('hello') 
@section('content') 
    <p>this is a test<p> 
    @yield('contents') 
@endsection 

文件:内容。 blade.php

@extends('tester.blade.php') 
@section('contents') 
    <p>any code will do<p> 
@endsection 

现在我的问题是当它只能渲染

Hello world 
this is a test 

是否有任何解决方法呢?或者刀片引擎不支持嵌套产量? anyhelp将不胜感激

回答

1

我没有测试过,但你可以尝试改变content.blade.php

@extends('tester') 

,并确保您使用

return view('content'); 

然而@include@section作品。或在content.blade.php

@extends('tester') 
@section('content') 
    @parent 
    <p>any code will do</p> 
@endsection 

@parent使用@parent会导致刀片追加与当前视图父视图的内容,而不是覆盖整个部分。

+0

谢谢,纠正了扩展,但不幸的是我忘了返回子视图,那是什么导致页面无法呈现 – Reyn