php - laravel blade, how to append to a section -
if laravel official documentation http://laravel.com/docs/4.2/templates says giving layout:
<!-- stored in app/views/layouts/master.blade.php --> <html> <body> @section('sidebar') master sidebar. @show <div class="container"> @yield('content') </div> </body> </html>
extended view
@extends('layouts.master') @section('sidebar') <p>this appended master sidebar.</p> @stop @section('content') <p>this body content.</p> @stop
will append section sidebar
. if seek doesn't append, override content extended template.
i heard others blade function @append, @prepend, @parent
... no 1 seems work.
beside, illustration in official doc doesn't work, find blade documentation poor. there's nil blade function @parent
instance.
the illustration in documentation larvel website indeed seem flawed, think it's markdown parsing problem on website, same docs on github show right code:
in case @parent
indeed work. illustration in docs should this:
@extends('layouts.master') @section('sidebar') @parent <p>this appended master sidebar.</p> @stop @section('content') <p>this body content.</p> @stop
a quick in illuminate/view/factory.php
confirms @parent
does:
/** * append content given section. * * @param string $section * @param string $content * @return void */ protected function extendsection($section, $content) { if (isset($this->sections[$section])) { $content = str_replace('@parent', $content, $this->sections[$section]); } $this->sections[$section] = $content; }
php laravel laravel-4 template-engine blade
No comments:
Post a Comment