Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

laravel blade template not rendering

Getting into laravel and im trying to work with blade templating but its not rendering. All my examples are coming for the laravel documentation.

UPDATE
So here is my master.blade.php file located in resources > views > master.blade.php

<!DOCTYPE html>
<html>
    <head>

        @yield('layouts.header')
    </head>
    <body>
        <div class="container">
            <div class="content">
                <div class="title">Test to Laravel 5</div>
            </div>
        </div>
    </body>
</html>

and here is my header.blade.php file located in view/layouts/

@section('header')
    <title>cookie monster</title>
    <link href="https://fonts.googleapis.com/css?family=Lato:100" rel="stylesheet" type="text/css">
    <style>
        html, body {
            height: 100%;
        }

        body {
            margin: 0;
            padding: 0;
            width: 100%;
            display: table;
            font-weight: 100;
            font-family: 'Lato';
        }

        .container {
            text-align: center;
            display: table-cell;
            vertical-align: middle;
        }

        .content {
            text-align: center;
            display: inline-block;
        }

        .title {
            font-size: 96px;
        }
</style>
@endsection

when i try to render my page no styles are being added even tho i have inline css at the moment, because i'm just testing how blade template engine works.

like image 230
hello world Avatar asked Dec 30 '15 08:12

hello world


1 Answers

You want to be using @include('layouts.header') rather than @yield.

@yield is what you use on a master template to specify where content will go that you can then define on a child view.

@include "allows you to easily include a Blade view from within an existing view." - https://laravel.com/docs/5.1/blade

like image 156
James Avatar answered Sep 18 '22 01:09

James