有没有包含Laravel刀片视图的部分的方法?仅包含Laravel刀片视图的部分
我有一个基本视图,通常包含在这个视图内的内容。有时我需要更多的自由度,想要更简单的基础,所以我将$special
标志设置为true。现在我有一种观点,可能都是作为一种“特殊”和正常观点出现的。有没有干净的方法来干这个?
base.blade.php
<!DOCTYPE html>
<html>
<head>
<title>@yield("title", "placeholder") - website</title>
</head>
<body>
@if (isset($special) && $special)
@yield("content")
@else
<header>
website
</header>
<main>
@yield("content")
</main>
<footer>© 2099</footer>
@endif
</body>
</html>
article.blade.php
@extends("base")
@section("title", "10 ways! You won't follow the last!")
@section("content")
So much content.
@endsection
other.blade.php
@extends("base", ["special" => true])
@section("title", "Welcome")
@section("content")
<div id="start">
Other stuff
</div>
<div id="wooo">
<main>
@include("article") ← does not work
</main>
<footer>© 2099</footer>
</div>
@endsection