Laravel / Blade-在同一页面上多次扩展同一模板

Meo*_*wts 2 laravel blade

所以必须有一种简单的解决方法...在我的网站上,有多种模式,具体取决于页面。我创建了一个模态模板,这些模板都可以扩展。但是,我在页面上包含的最后一个模态最终“接管”了其余的模态,因此,我所有的模态最后都包含了最后一个包含的相同部分。如何使每个扩展名对其扩展文件都是唯一的?

发生的事的示例:

//template.blade.php
<htmls and stuff>
    @yield('section_1')
    @yield('section_2')
</htmls and stuff>

//Modal 1
@extends('template')
@section('section_1')
    Some words
@stop
@section('section_2')
    More words
@stop

//Modal 2
@extends('template')
@section('section_1')
    Rabbit
@stop
@section('section_2')
    Stew
@stop
Run Code Online (Sandbox Code Playgroud)

我没有加载两个独特的模态,而是得到了两个装满Rabbit Stew的模态。

小智 6

尝试使用@overwrite命令代替@endsection

例:

@section('stuff')
     Stuff goes here...
@overwrite
Run Code Online (Sandbox Code Playgroud)

资料来源:https : //github.com/laravel/framework/issues/1058#issuecomment-17194530