Note that there are some explanatory texts on larger screens.

plurals
  1. PO
    text
    copied!<p><em>For Laravel 5.4, <a href="https://laravel.com/docs/5.4/blade#components-and-slots" rel="nofollow noreferrer">Components &amp; Slots</a> may be useful for you. The following solution is for Laravel 4.x, and likely &lt;= 5.3 as well.</em></p> <hr> <p>In my opinion, this is a silly use case for the <code>@include</code> syntax. The amount of HTML retyping you're saving is negligible, especially since the only potentially-complicated part of it is the <code>inner</code> content. Keep in mind, the more parsing that needs to be done, the more overhead your application has, also.</p> <p>Also, I don't know the inner workings of the <code>@yield</code> &amp; <code>@section</code> features, so I can't say how "proper" it is to work your includes this way. Includes typically utilize a key => value pair passed as a parameter in the include call:</p> <pre><code>@include('panel', ['heading' =&gt; 'Welcome', 'inner' =&gt; '&lt;p&gt;Some stuff here.&lt;/p&gt;']) </code></pre> <p>Not the most ideal place to pack a bunch of HTML, but that's the "designed" way (as far as I know, at least).</p> <p><strong>That said...</strong></p> <p>Use the <code>@section ... @overwrite</code> syntax mentioned in the <a href="https://laravel.com/docs/4.2/templates#other-blade-control-structures" rel="nofollow noreferrer">"Other Control Structures"</a> part of the template docs page.</p> <pre><code>@extends('default') @section('content') {{-- First Panel --}} @section('heading') Welcome, {{ $user-&gt;name }} @overwrite @section('inner') &lt;p&gt;Welcome to the site.&lt;/p&gt; @overwrite @include('panel') {{-- Second Panel --}} @section('heading') Your Friends @overwrite @section('inner') &lt;ul&gt; @foreach($user-&gt;friends as $friend) &lt;li&gt;{{ $friend-&gt;name }}&lt;/li&gt; @endforeach &lt;/ul&gt; @overwrite @include('panel') @stop </code></pre>
 

Querying!

 
Guidance

SQuiL has stopped working due to an internal error.

If you are curious you may find further information in the browser console, which is accessible through the devtools (F12).

Reload