Laravel header content appears in body tag

I am new to Laravel and I am trying to create my first layout for the new site that I am doing.

The problem is that the content that I want in <head>is in <body>, but <head>empty.

I have:

layout.blade.php

<!DOCTYPE html>
<html>
    <head>
        <title>@section('title')</title>
        {{ HTML::style('https://maxcdn.bootstrapcdn.com/bootstrap/3.2.0/css/bootstrap.min.css'); }}
    </head>

    <body>
        <h1>@yield('h1')</h1>
        @yield('content')
        {{ HTML::script('js/jquery-1.11.1.min.js'); }}
        {{ HTML::script('https://maxcdn.bootstrapcdn.com/bootstrap/3.2.0/js/bootstrap.min.js'); }}
    </body>
</html>

users.blade.php

@extends('layouts.layout')

@section('title')
    Users Page - 1

@section('h1')
    <?PHP echo $h1;?>
@stop

Where am I going wrong?

And what is the difference in @yeildand @sectionin my opinion?

+4
source share
2 answers

Try this at layout.blade.php . You are expanding this blade template, so you must use the tag @yield('title')in the tag <title>, and you must @stopeach@section

<!DOCTYPE html>
<html>
    <head>
        <title>@yield('title')</title>
        {{ HTML::style('https://maxcdn.bootstrapcdn.com/bootstrap/3.2.0/css/bootstrap.min.css'); }}
    </head>

<body>
    <h1>@yield('h1')</h1>
    @yield('content')
    {{ HTML::script('js/jquery-1.11.1.min.js'); }}
    {{ HTML::script('https://maxcdn.bootstrapcdn.com/bootstrap/3.2.0/js/bootstrap.min.js'); }}
</body>

0
source

yield , , -, :

<!DOCTYPE html>
<html>
<head>
    <title></title>
</head>
    <body>
        @yield('content')
    </body>
</html>

- :

extends('layouts.master')

@section('content')
   Everything within this section will be dumped
   in to `@yield('content')` in your master layout.
@stop

@stop , . , - :

<!DOCTYPE html>
<html>
    <head>
        <title>{{ $title }}</title>
        {{ HTML::style('https://maxcdn.bootstrapcdn.com/bootstrap/3.2.0/css/bootstrap.min.css') }}
    </head>
    <body>

        @yield('content')

        {{ HTML::script('js/jquery-1.11.1.min.js'); }}
        {{ HTML::script('https://maxcdn.bootstrapcdn.com/bootstrap/3.2.0/js/bootstrap.min.js'); }}
    </body>
</html>

controller , :

return View::make('viewname')->with('title', $title);

Templates - Laravel.

+2

All Articles