Laravel - Check if @yield empty or not

后端 未结 17 1923
醉梦人生
醉梦人生 2021-01-31 02:08

Is it possible to check into a blade view if @yield have content or not?

I am trying to assign the page titles in the views:

@section(\"title\", \"hi wor         


        
17条回答
  •  说谎
    说谎 (楼主)
    2021-01-31 02:33

    New in Laravel 7.x -- sectionMissing():

    @hasSection('name')
       @yield('name')
    @else
       @yield('alternative')
    @endif
    

    Check if section is missing:

    @sectionMissing('name')
       @yield('alternative')
    @endif
    

提交回复
热议问题