Laravel Blade Template - Adding On To A Section
Today, I wanted to show you how to add onto the
@section of a blade template without overriding anything that is inside the section in the “master” layout blade file!
Below is the example “master” layout blade file:
Now let’s say we want to add a stylesheet for just our single view and keep all that is included in our “master” template file, we would have the following file created for our view with the following to add the css file and not override everything within the
By adding the
@parent inside the
@section('styles') you are including everything like we wanted in the “master” template file! And then everything works exactly how you would expect it to, if you add files before or after the
@parent, it will show up before or after.
I hope this helped! Comment below with any questions or for any information to add to this article. I have more Laravel articles coming!