vendredi 22 janvier 2016

Laravel 5 - strange output from extending layouts

I have only noticed this by mistake because it does not seem to cause any problems, but I want to make sure it is ok.

So I have a header.blade.php which takes the following form

<!DOCTYPE html>
<html>
<head>
    <title>Some title</title>

    <meta name="viewport" content="width=device-width, initial-scale=1.0">
    <meta http-equiv="X-UA-Compatible" content="IE=edge">

    {!! HTML::style('css/jquery-ui.min.css') !!}
    {!! HTML::style('css/bootstrap.min.css') !!}
    {!! HTML::style('font-awesome/css/font-awesome.min.css') !!}
    {!! HTML::style('css/style.css') !!}

</head>

<body>

<div id="wrapper">

    <nav class="navbar navbar-inverse navbar-fixed-top" role="navigation">
        // Navigation code
    </nav>

    <div id="page-wrapper">

        @yield('content')

I then have footer.blade.php which looks something like this

    </div>
    <!-- /#page-wrapper -->

</div>
<!-- /#wrapper -->

{!! HTML::script('js/jquery.js'); !!}
{!! HTML::script('js/jquery-ui.min.js'); !!}
{!! HTML::script('js/bootstrap.min.js'); !!}
{!! HTML::script('js/main.js'); !!}


</body>

</html>

So pretty straight forward at the moment. I then have a template page that I am working on, say test.blade.php. This looks something like the following

@extends('header')

@section('content')

<div class="container-fluid">

    <div class="row">
        <div class="col-lg-12">
            <h1 class="page-header">
                Management
            </h1>
        </div>
        // Other content
    </div>

</div>
<!-- /.container-fluid -->

@endsection

@extends('footer')

From what I understand, this is all correct so far. However, if I view the source generated for test.blade.php, it looks like so

</div>
<!-- /#page-wrapper -->

</div>
<!-- /#wrapper -->

<script src="http://localhost:8000/js/jquery.js"></script>
<script src="http://localhost:8000/js/jquery-ui.min.js"></script>
<script src="http://localhost:8000/js/bootstrap.min.js"></script>
<script src="http://localhost:8000/js/main.js"></script>



</body>

</html>

<!DOCTYPE html>
<html>
<head>
    <title>Some title</title>

    <meta name="viewport" content="width=device-width, initial-scale=1.0">
    <meta http-equiv="X-UA-Compatible" content="IE=edge">

    <link media="all" type="text/css" rel="stylesheet" href="http://localhost:8000/css/jquery-ui.min.css">
    <link media="all" type="text/css" rel="stylesheet" href="http://localhost:8000/css/bootstrap.min.css">
    <link media="all" type="text/css" rel="stylesheet" href="http://localhost:8000/font-awesome/css/font-awesome.min.css">
    <link media="all" type="text/css" rel="stylesheet" href="http://localhost:8000/css/style.css">

</head>

<body>

<div id="wrapper">

    <nav class="navbar navbar-inverse navbar-fixed-top" role="navigation">
        // Navigation code
    </nav>

    <div id="page-wrapper">

        <div class="container-fluid">

            <div class="row">
                <div class="col-lg-12">
                    <h1 class="page-header">
                        Management
                    </h1>
                </div>
                // Other content
            </div>

        </div>
        <!-- /.container-fluid -->

So the obvious question here, why is it showing my footer code at the top of the file?



via Chebli Mohamed

Aucun commentaire:

Enregistrer un commentaire