Can a blade cut a part in one file?

I have a master.blade.php file that contains @yield('mainsection'). Then I have another file:

@extends('layouts.master')

@section('mainection')
    test1
    @yield('othersection')
@stop

@section('othersection')
    test2
@stop

I see test1, but not test2- from which I conclude that the blade does not allow you to go to the section defined in the same file. Is there any way around this? Or do I need to add a third file between the two in order to contain the main part and give way to the others?

+3
source share
1 answer

it can be shown, but @section must be written before @yield

@extends('layouts.master')

@section('othersection')
  test2
@stop

@section('mainection')
  test1
  @yield('othersection')
@stop
+6
source

All Articles