phplaravellaravel-blade

Laravel blade: Can you yield a default partial


If I have a layout called RightSideBar.blade.php in Laravel blade, one area yield('content') and the other yield('sidebar').

Is there a built in way to display a default partial if the view that is extending RightSideBar does not have a section('sidebar')?

I know you can pass a value by default, just wondering if there is a way to make default a partial.


Solution

  • Yes you can pass a default

    Looking at the documentation

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

    Which basically puts a default output when the child template does not have @section('sidebar')