laravel刀片模板不渲染

hel*_*rld 5 php laravel laravel-5.1 laravel-blade

进入laravel,我尝试使用刀片模板,但未进行渲染。我所有的示例都将用于laravel文档。

更新
所以这是我的master.blade.php文件,位于资源>视图> master.blade.php中

<!DOCTYPE html>
<html>
    <head>

        @yield('layouts.header')
    </head>
    <body>
        <div class="container">
            <div class="content">
                <div class="title">Test to Laravel 5</div>
            </div>
        </div>
    </body>
</html>
Run Code Online (Sandbox Code Playgroud)

这是我的header.blade.php文件,位于view / layouts /

@section('header')
    <title>cookie monster</title>
    <link href="https://fonts.googleapis.com/css?family=Lato:100" rel="stylesheet" type="text/css">
    <style>
        html, body {
            height: 100%;
        }

        body {
            margin: 0;
            padding: 0;
            width: 100%;
            display: table;
            font-weight: 100;
            font-family: 'Lato';
        }

        .container {
            text-align: center;
            display: table-cell;
            vertical-align: middle;
        }

        .content {
            text-align: center;
            display: inline-block;
        }

        .title {
            font-size: 96px;
        }
</style>
@endsection
Run Code Online (Sandbox Code Playgroud)

当我尝试呈现我的页面时,即使我现在有内联CSS,也没有添加任何样式,因为我只是在测试刀片模板引擎的工作方式。

Jam*_*mes 6

您想使用@include('layouts.header')而不是@yield

@yield 是您在主模板上使用的内容,用于指定内容的去向,然后您可以在子视图中定义内容。

@include“使您可以轻松地从现有视图中包含刀片视图。” - https://laravel.com/docs/5.1/blade

  • 这是正确的答案,请使用include并删除@section('header')和@endsection (2认同)