Skip to content
Advertisement

laravel blade, how to append to a section

If you look to laravel official documentation http://laravel.com/docs/4.2/templates It says that giving this layout:

JavaScript

Extended by this view

JavaScript

Will append to the section sidebar. But actually if you try is it doesn’t append, it just override the content from the extended template.

I heard about others blade function like @append, @prepend, @parent… no one seems to work.

Beside, this example in the official doc which doesn’t work, I find that the blade documentation is very poor. There’s nothing about blade function like @parent for instance.

Advertisement

Answer

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:

JavaScript

A quick look in the Illuminate/View/Factory.php confirms what @parent does:

JavaScript
User contributions licensed under: CC BY-SA
8 People found this is helpful
Advertisement