Laravel:仅在子节点中存在时才添加节

时间:2017-04-19 03:24:01

标签: laravel-5.4 laravel-blade

我已经定义了包含页眉,页脚和内容部分的app.blade.php

<html>
<head>
....
<title>@yield('title')<title>
<meta type='description' content="@yield('description')">
...
</head>
<body>
..
@yield('content')
..
</body>
</html>

在我延长app.blade的所有子刀片中,我必须为description定义一个值,否则它将为空,谷歌将在搜索结果中没有显示它的描述:

 @extend('app')
    @section('title','a title')
    @section('description','something')
    @section('content')
     ....
    @endsection

如果我没有在已延长description的子刀片中定义它,我怎么能阻止app.blade元包含在头部?

1 个答案:

答案 0 :(得分:1)

我应该使用hasSection指令,如here

所述
相关问题