如何清除blade.php中定义的节

如何清除blade.php中定义的节,php,laravel-blade,Php,Laravel Blade,我知道这一点,但我想知道是否有可能在同一个文件中清除或重新定义一个已定义的节 例如,类似于: @section('scripts') <script src="/example.js"></script> @endsection //something like @section('scripts') // nothing @endsection // now the 'scripts' stack is an empty b

我知道这一点,但我想知道是否有可能在同一个文件中清除或重新定义一个已定义的节

例如,类似于:

@section('scripts')
    <script src="/example.js"></script>
@endsection


//something like
@section('scripts')
    // nothing
@endsection



// now the 'scripts' stack is an empty block of code.


 //print
 {{  @yield('scripts')  }}
@节(“脚本”)
@端部
//差不多
@节(“脚本”)
//没什么
@端部
//现在,“脚本”堆栈是一个空代码块。
//印刷品
{{@yield('scripts')}

我找到了一种方法,只需在普通php中使用
ob_start()

        @php
            ob_start();
        @endphp
            // write blade code here
        @php
            $scripts = ob_get_contents();
            ob_end_clean();
        @endphp
        
          //print
         {!! $scripts !!}

在同一个文件中?那有什么用?你先把它推入堆栈,然后清除它?那为什么先推?谢谢,问错了问题。本应改为分区。这次清理的目的是什么?你到底想达到什么目的?我的任务是翻译一个小树枝文件。。有一个视图,需要注入多个文件。它的工作原理是有一个循环,循环通过不同目录中的一堆其他文件。在twig中,随着循环的进行,它们将在块内使用include语句进行iport。Twig自动重新定义include语句块,而我在为blade重新定义等价的“block”/(section)时遇到了麻烦。