Solution:1
The example in the documentation from Laravel website does indeed seem to be flawed, but I think it’s a markdown parsing problem on the website, the same docs on github show the correct code:
In any case @parent
does indeed work. The example in the docs should look like this:
@extends('layouts.master')
@section('sidebar')
@parent
<p>This is appended to the master sidebar.</p>
@stop
@section('content')
<p>This is my body content.</p>
@stop
A quick look in the Illuminate/View/Factory.php
confirms what @parent
does:
/**
* Append content to a 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;
}