html - Laravel <title> in <body> -


i mixed 2 examples laravel tutorial,and receive result, hope me understand. route file :

route::get('/', function () { return view('child', ['name' => 'samantha']); 

child.blade.php

@extends('layouts.master')  @section('title', 'page title')  @section('sidebar')     @parent      <p>this appended master sidebar.</p> @endsection hello, {{ $name }}. @section('content')     <p>this body content.</p> @endsection 

and master.blade.php

<html>     <head>         <title>app name - @yield('title')</title>     </head>     <body>          @section('sidebar')             master sidebar.         @show          <div class="container">             @yield('content')         </div>     </body> </html> 

output

hello, samantha. master sidebar. appended master sidebar. body content. 

page source code

hello, samantha.  <html>     <head>         <title>app name - page title</title>     </head>     <body>                          master sidebar.       <p>this appended master sidebar.</p>          <div class="container">                 <p>this body content.</p>         </div>     </body> </html> 

inspecting tool shows me empty <head> , <title> in <body> .

why happens hello, {{ $name }} , why inspecting tool lie me page body?

and、 if put in @section hello, {{ $name }} fine.

as child template extends layout, data have in must enclosed section

hello, {{ $name }}. isn't in section print @ top of output.

you can see extending template buffer. starts taking contain of child because it's file provide in controller, wrap it's content in sections defined in layout.


Comments

Popular posts from this blog

javascript - Thinglink image not visible until browser resize -

firebird - Error "invalid transaction handle (expecting explicit transaction start)" executing script from Delphi -

mongodb - How to keep track of users making Stripe Payments -