Add Body Class on Laravel Views
CSS, Laravel
It is useful to add resource-specific classes to the body class of a page to allow elements to be targeted by CSS.
Pass Variable from Child View to Master Layout
Pass a relevant variable from the blade template:
Then in /views/layouts/master.blade.php
:
You need to check that the variable is not empty - otherwise, if $body_class
isn’t passed in to the master template an error will occur.
Use @section
In the child blade template:
In the master:
References
https://www.reddit.com/r/laravel/comments/3i44nz/how_do_i_add_body_class_for_each_page/
comments powered by Disqus