有没有办法只包含 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