Laravel Blade: @endsection vs @stop
Asked Answered
S

3

44

In Laravel Blade, we can basically do this:

@section('mysection')

@endsection


@section('mysection')

@stop

What is the difference between @stop and @endsection?

Structure answered 18/1, 2014 at 2:51 Comment(1)
Both work @endsection and @stop. I find @endsection feels more intuitive. that's why i also use @endsection in laravel 8. Note: in the laravel 8 documentation you won't find anything more about `@stop.Gamma
C
33

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

Creamcups answered 18/1, 2014 at 4:7 Comment(5)
but still usable (even in the 5 version)Rienzi
i don't think it's deprecated anymore, they even use it as an example in the currenet version docs. no notice of the @stop keyword laravel.com/docs/5.1/bladeBroadcloth
@endsection isn't 'deprecated' anymore in Laravel 5.2, so this answer should be updated.Illuminism
And the link is dead.Salvage
It is not deprecated. If you look at Laravel's official documentation, even in version 6.0 they are still introducing @endsection for the blade.Quinquevalent
S
18

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:

Steroid answered 5/2, 2019 at 8:38 Comment(1)
Because of the change in direction of Laravel, this is now the correct answer!Czechoslovak
V
15

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

Viosterol answered 24/10, 2015 at 18:20 Comment(0)

© 2022 - 2024 — McMap. All rights reserved.