Is it possible to yield to another view but then default with an include statement?
Example:
@yield('header', @include('partials.header'))
The intended action is that if the subview does not include the header, then the current template will include the partials.header view.
In Laravel, @yield is principally used to define a section in a layout and is constantly used to get content from a child page unto a master page.
The Blade is a powerful templating engine in a Laravel framework. The blade allows to use the templating engine easily, and it makes the syntax writing very simple. The blade templating engine provides its own structure such as conditional statements and loops.
In addition to template inheritance and displaying data, Blade also provides convenient shortcuts for common PHP control structures, such as conditional statements and loops. These shortcuts provide a very clean, terse way of working with PHP control structures while also remaining familiar to their PHP counterparts.
Yes you can use it where ever you like.
It is possible. But you can't use blade tags inside blade tags. What you can do however is use View::make()
instead of @include
. @include
actually compiles to a make
call on the view factory.
@yield('header', View::make('partials.header'))
If you love us? You can donate to us via Paypal or buy me a coffee so we can maintain and grow! Thank you!
Donate Us With