Laravel 在@section 之后删除@include

Laravel Blade @include after @section

为什么 Blade 在渲染输出的部分之前包括下面所示的测试代码?有没有办法放在节后或节中?

// Specify the filename of the layout (without extension)
@extends('layout')

// The rest of the code of the view template
// Opening content section
@section('content')
  // The content that will be injected in the layout replacing “@yield(‘content’)”
  This is the home pagevvvvvvvvvvvvvvvvvvvvvvvvvvvvvvvvvvvvvvv
// Closing content section
@stop


@section('content')
  <p>This is just Content</p>
@stop

@section('moreContent')
  <p>This is More Content</p>
@stop

@section('evenMoreContent')
  <p>This is Even More Content</p>
@stop

@include('navigation')

不,我认为没有办法做到这一点,并且当您扩展模板时,唯一呈现的是 layout 和您定义的部分。

如果您想更改输出顺序,可以在 layout 文件中执行此操作。

您应该编辑扩展模板。您可以在 template 文件 (@yield('naveigation')) 中添加另一个部分,稍后再定义 navigation 部分。

在此文件中:

@section('navigation')
  @include('navigation')
@stop

并且在layout.blade.php

Layout
<br>
Nav:
<br>
@yield('navigation')
<br>
Content:
<br>
@yield('content')