Note that there are some explanatory texts on larger screens.

plurals
  1. POHow to reuse a blade partial in a template
    primarykey
    data
    text
    <p>I would like to be able to repeat a partial a number of times within a view, with different content in each repetition.</p> <p>The partial is a simple panel, with a heading, and some content. The content within each panel can vary in complexity, so I would like to be able to use the <code>@section('content')</code> method of passing data.</p> <p>The set up I have is as follows:</p> <p><em>panel.blade.php</em> - The partial to be repeated.</p> <pre><code>&lt;div class="panel"&gt; &lt;header&gt; @yield('heading') &lt;/header&gt; &lt;div class="inner"&gt; @yield('inner') &lt;/div&gt; &lt;/div&gt; </code></pre> <p><em>view.blade.php</em> - The view in which the partial is repeated</p> <pre><code>@extends('default') @section('content') {{-- First Panel --}} @section('heading') Welcome, {{ $user-&gt;name }} @stop @section('inner') &lt;p&gt;Welcome to the site.&lt;/p&gt; @stop @include('panel') {{-- Second Panel --}} @section('heading') Your Friends @stop @section('inner') &lt;ul&gt; @foreach($user-&gt;friends as $friend) &lt;li&gt;{{ $friend-&gt;name }}&lt;/li&gt; @endforeach &lt;/ul&gt; @stop @include('panel') @stop </code></pre> <p>I am running into the same issue as this: <a href="http://forums.laravel.io/viewtopic.php?id=3497" rel="noreferrer">http://forums.laravel.io/viewtopic.php?id=3497</a></p> <p>The first panel is displayed as intended, but the second is simply a repeat of the first.</p> <p>How can I correct this? If this is a poor method of getting this done, what would be a better way?</p>
    singulars
    1. This table or related slice is empty.
    1. This table or related slice is empty.
    plurals
    1. This table or related slice is empty.
    1. This table or related slice is empty.
    1. This table or related slice is empty.
    1. This table or related slice is empty.
 

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