CSS Blade Laravel

2

I'm starting now with Laravel 5.1, I was left with a question regarding blade.

For example, I want to pass several CSS or JS files from the page in question using Blade notation. My main file looks like this:

<html>
<head>
    <link href="@yield('css')" rel="stylesheet">
    <title>@yield('titulo')</title>
</head>

And on the page like this:

@section('css', '/css/app.css')

How can I make a page load several CSS files? Is it possible?

    
asked by anonymous 08.07.2015 / 04:33

1 answer

1

You can create this in a different way by creating a @section only for CSS on your main page. It's interesting to put views there that all pages will use:

// trecho do arquivo layouts/master.blade.php
@section('style')
    <link href="/css/app.css" rel="stylesheet">
@show

And in views based on layouts/master , you will place specific page views.

@extends('layouts.master')

@section('style')
    @parent
    <link href="/css/app2.css" rel="stylesheet">
    <link href="/css/app3.css" rel="stylesheet">
    <link href="/css/app4.css" rel="stylesheet">        
@endsection

The @parent will pull the contents of @section parent and put the specific content below. If you want to overwrite the contents of @section just do not put @parent

    
08.07.2015 / 13:12