Support the ongoing development of Laravel.io →
posted 7 years ago
Blade
Last updated 1 year ago.
0

just replace @endsection with @stop, i think that would be helpful for you

0

Get the clear idea on template inheritance

You need to understand how blade template inheritance work. Take some time, and read this awesome documentation!

Here is a good explanation:


├─── main.blade.php [Parent layout, with @yield]
│
│         └─── section.blade.php   [This is the children, with @section]
│         └─── otherfile.blade.php  [This is another children, @section]

Remember, when using @yield, it always return empty if you access the file directly as view. It is special made for children. Just like you give a baby formulated milk, you don't drink it, your baby does! Thus, access it ONLY with children when using @yield and @section

How to deal with it?

In your router, you have to set the view as

    public function section(){
	    return view('section.blade.php');
    }

Extra Tips - Using @include:

@include guide

If you want to view the parent instead, and include the children inside it, feel free to use @include tag as follow in your parent template file.

@include('section')

├─── main.blade.php [Parent layout, with @include('section')]
│
│         └─── section.blade.php   [This is the children to be included]
│         └─── otherfile.blade.php  [This is another children]

Last updated 7 years ago.
0

Sign in to participate in this thread!

Eventy

Your banner here too?

superrupe superrupe Joined 27 Sep 2016

Moderators

We'd like to thank these amazing companies for supporting us

Your logo here?

Laravel.io

The Laravel portal for problem solving, knowledge sharing and community building.

© 2024 Laravel.io - All rights reserved.