Как сдать внутри включенного шаблона с laravel? - PullRequest
0 голосов
/ 03 июня 2019

С Blade кажется, что yield не работает с включенными частями.Как заполнить раздел, определенный внутри включенной части в родительском шаблоне?

Кажется, это известная проблема: https://github.com/laravel/framework/issues/8970

template-body.blade.php

<body>
@yield('body')
<body>

template-html.blade.php

<html>
@include('template-body')
@yield('other')
</html>

foo.blade.php

@extends('template-html')
@section('body')
Hello World! (does not work)
@endsection
@section('other')
Does work
@endsection

1 Ответ

0 голосов
/ 03 июня 2019

то, что вы делаете, даст вам ошибку.Вы можете включить страницы в шаблон и другие подстраницы.это зависит только от того, что вы делаете и как вы это делаете.то, что вы должны были сделать:

//app.layout
 <!DOCTYPE html>
<html>
<head>
<title>@yield('title')</title>
<your-css-files>
@yield('styles')
<your-script files>
@yield('scripts')
</head>
<body>
@include('your page')
@yield('content')

</body>
</html> 

, то на своих страницах вы делаете:

@extends(app.layout)
@section('content')
<h1>This is a Heading</h1>
<p>This is a paragraph.</p>
@include('your page')
@endsection

on the samepage you can call your styles and scripts as

@section('styles')
 //css files
@stop

@section('scripts')
 // javascript files
@stop
Добро пожаловать на сайт PullRequest, где вы можете задавать вопросы и получать ответы от других членов сообщества.
...