简体   繁体   English

Laravel Blade @include在@section之后

[英]Laravel Blade @include after @section

Why does Blade includes goes before sections in the rendered output the tested code shown below? 为什么Blade在呈现的输出中的各个部分之前都包含如下所示的经过测试的代码? Is there a way to put after or the middle of sections? 有没有办法放在节的后面或中间?

// 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')

No, I see no way to do that, and as you are extending a template the only thing that is being rendered is the layout with the sections you define. 不,我看不到这样做的方法,并且在扩展模板时,唯一呈现的内容是具有定义的部分的layout

If you want to change the order in the output, the layout file is where you can do this. 如果要更改输出中的顺序,则可以在layout文件中执行此操作。

You should edit the extended template. 您应该编辑扩展模板。 You can add another section in the template file ( @yield('naveigation') ) and the define the navigation section later. 您可以在template文件中添加另一个部分( @yield('naveigation') ),稍后再定义navigation部分。

In this file: 在此文件中:

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

And in layout.blade.php 并在layout.blade.php

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

声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM