我在应用布局中使用相同的部分两次。我像这样传递变量:
<body>
<div class="background-container">
<img src="{{ asset('/img/cover_art.jpg') }}" alt="" />
</div>
@section('topBar')
@include('customer.layouts.partials.top-bar')
@show
<div class="panel">
@section('carousel')
@include('customer.layouts.partials.carousel', ['section' => 'header-carousel'])
@show
</div>
<div class="container">
@section('magazine-detail')
@include('customer.layouts.partials.magazine-detail')
@show
<div class="show-for-medium">
@section('carousel')
@include('customer.layouts.partials.carousel', ['section' => 'footer-carousel'])
@show
</div>
</div>
@section('scripts')
@include('customer.layouts.partials.scripts')
@show
</body>
然后在部分我得到这样的变量:
<section class="carousel {{ $section }}">
问题是我得到了两个部分header-carousel
的相同值。我该如何解决这个问题?
这是精简的html输出:
<nav class="side-nav">
</nav>
<section class="top-bar">
...
</section>
<section class="carousel header-carousel">
...
</section>
<section class="row magazine-detail">
...
</section>
<section class="carousel header-carousel">
...
</section>