Masud Rana
Masud Rana

Reputation: 103

In Laravel 5.4 ,Is it possible to include a specific CSS file for a certain blade template?

I have tried the following in my blade template:

@section('styles')
<link href="{{asset('assets/css/app.css')}}" />
@stop

In the master blade template I have included the following:

<link href=asset('/assets/template/css//invoiceTemplate.css')rel="stylesheet" type="text/css"/>

Upvotes: 0

Views: 270

Answers (3)

Joshua Arosco
Joshua Arosco

Reputation: 36

Yes it is. Write this code to your master template

@yield('page-styles')

and add this also to the specific blade file where you want to add a specific CSS file.

@section('page-styles')
    //Your specific css file
@stop

Make sure that the parameter inside the @section and @yield are the same. In this case, I've used 'page-styles'.

Upvotes: 0

plmrlnsnts
plmrlnsnts

Reputation: 1684

You need to add @yield('styles') to your master blade template.

Upvotes: 0

Yeeooow
Yeeooow

Reputation: 308

I you want to include a CSS / JS file for a specific blade use stacks (see here)

from the documentation:

@push('scripts')
    <script src="/example.js"></script>
@endpush

You may push to a stack as many times as needed. To render the complete stack contents, pass the name of the stack to the @stack directive:

<head>
    <!-- Head Contents -->

    @stack('scripts')
</head>

you can also place them at the bottom of your blade (where a lot of people call thier JS files these days)

Upvotes: 1

Related Questions