Same section name in blade inherited templates

Viewed 3368

Let's say i have three blade templates: A, B and C. Template A is the global layout, template B is some specific section's layout and template C is the view template.

Templates A and B expect a section called content to be assigned. That section is defined in the view templates (C).

Here's a simplified version of templates A and B:

Template A:

<html>
  <body>
    @yield('content')
  </body>
</html>

Template B:

@extends('template_a')

@section('content')
<div class="sidebar">
  ...
</div>
<div class="content">
  @yield('content')
</div>
@endsection('content')

As you can see, both templates output a content section. My problem is that in views that extend B it's content is simply ignored. The content section defined in the view is output on the @yield('content') present at template A.

I would like to know if it is possible to propagate the content section up in the view hierarchy, i.e., replacing the the content placeholder in template B with the value defined in template C and replace the result in content placeholder in template A.

Sorry if i made this sound too confusing. I hope you get my idea.

Thanks in advance.

2 Answers
Related