我正在研究 Blade 如何实现 @section,但它的工作方式与我习惯的 Twig 略有不同。看来你不能将@sections嵌套在一起。
Example:
_layout.blade.php(基本布局文件)
<html>
//favicons
//meta content
//other basic shizzle
<head>
<title>overal</title>
</head>
<body>
@yield('body_content')
</body>
</html>
网站.blade.php(具体实施)
@extend('_layout.blade.php')
@section('body_content')
<div class="">
website-header
</div>
<div class="main">
@section('navigation')
<nav>website navigation</nav>
@endsection
<div class="website">
{-- the actual content --}
@yield('content')
</div>
</div>
@endsection
博客.blade.php(博客页面的实现)
@extend('website.blade.php')
@section('content')
blog-items
@endsection
常见问题解答.blade.php(常见问题解答页面的实现)
@extend('website.blade.php')
{{-- we don't want the navigation here or want something different --}}
@section('nav')@endsection
@section('content')
faq-items
@endsection
我无法使用 @includes 解决它,因为我希望能够灵活地确定子视图中的子子部分并覆盖其内容。
没关系,这个is可能的
困扰我的是我的编辑(PhpStorm)。你CAN相互嵌套@section并在扩展模板中覆盖/重新定义它们^^
W00000t
本文内容由网友自发贡献,版权归原作者所有,本站不承担相应法律责任。如您发现有涉嫌抄袭侵权的内容,请联系:hwhale#tublm.com(使用前将#替换为@)