vendredi 18 septembre 2015

Laravel 5 prepend to view parent section

I'm writing a webpage using Laravel 5.0 and would like to modularize sections of a view. Currently I have master >> view >> partial templates.

master.blade.php

<head>
    <!-- master's css -->
    @yield('css')
</head>
<body>
    @yield('content')
</body>

view.blade.php

@extends('master')
@section('css')
    <!-- view-specific css -->
@stop
@section('content')
    <!-- some content -->
    @include('partial')
@stop

partial.blade.php

@section('css')
    @parent
    <!-- partial-specific css -->
@append

<!-- partial's content -->

How it loads:

<head>
    <!-- master's css -->
    <!-- view-specific css -->
    <!-- partial-specific css -->
</head>

How I want it to load:

<head>
    <!-- master's css -->
    <!-- partial-specific css -->
    <!-- view-specific css -->
</head>

I've tried moving the @parent before and after the view-specific css but the page loads the partial-specific css after the view css regardless.

My reasoning is that I'd like to have the last css sheet from the view template to be the last loaded so that I may overwrite some of the partial's css if needed for a particular page that uses it.

Thanks in advance.



via Chebli Mohamed

Aucun commentaire:

Enregistrer un commentaire