Laravel Blade: @endsection vs @stop

北战南征 提交于 2019-12-18 18:49:39

问题


In Laravel Blade, we can basically do this:

@section('mysection')

@endsection


@section('mysection')

@stop

What is the difference between @stop and @endsection?


回答1:


The @endsection was used in Laravel 3 and it was deprecated in Laravel 4

In the Laravel 4 to end a section you have to use @stop

You can refer the Changelog here http://wiki.laravel.io/Changelog_%28Laravel_4%29#Blade_Templating




回答2:


Authoritative answer by Taylor Otwell

@endsection became @stop in L4, just as @yieldSection became @show.

At github, Taylor Otwell said

@stop is just @endsection from L3.. @show is just @yieldSection




回答3:


Both @endsection and @stop works.

In Laravel 4 it seems that only @stop is supported 1. But from Laravel 5 onwards @stop is not even mention in the documentation 2.

So I would suggest to use @endsection.

See:

  • Laravel 4 Blade Documentation
  • Laravel 5.7 Blade Documentation (current stable)


来源:https://stackoverflow.com/questions/21199412/laravel-blade-endsection-vs-stop

易学教程内所有资源均来自网络或用户发布的内容,如有违反法律规定的内容欢迎反馈
该文章没有解决你所遇到的问题?点击提问,说说你的问题,让更多的人一起探讨吧!