Laravel - Check if @yield empty or not

后端 未结 17 1917
醉梦人生
醉梦人生 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:32

    Given from the docs:

    @yield('section', 'Default Content');
    

    Type in your main layout e.g. "app.blade.php", "main.blade.php", or "master.blade.php"

    {{ config('app.name') }} - @yield('title', 'Otherwise, DEFAULT here')
    

    And in the specific view page (blade file) type as follows:

    @section('title')
    My custom title for a specific page
    @endsection
    

提交回复
热议问题