Laravel Blade: @endsection vs @stop

2019-02-16 06:57发布

In Laravel Blade, we can basically do this:

@section('mysection')

@endsection


@section('mysection')

@stop

What is the difference between @stop and @endsection?

3条回答
三岁会撩人
2楼-- · 2019-02-16 07:00

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

查看更多
老娘就宠你
3楼-- · 2019-02-16 07:02

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

查看更多
forever°为你锁心
4楼-- · 2019-02-16 07:21

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:

查看更多
登录 后发表回答