Laravel 4 主布局未渲染

声明:本页面是StackOverFlow热门问题的中英对照翻译,遵循CC BY-SA 4.0协议,如果您需要使用它,必须同样遵循CC BY-SA许可,注明原文地址和作者信息,同时你必须将它归于原作者(不是我):StackOverFlow 原文地址: http://stackoverflow.com/questions/16756551/
Warning: these are provided under cc-by-sa 4.0 license. You are free to use/share it, But you must attribute it to the original authors (not me): StackOverFlow

提示:将鼠标放在中文语句上可以显示对应的英文。显示中英文
时间:2020-09-14 07:49:15  来源:igfitidea点击:

Laravel 4 master layout not rendering

laravellaravel-4

提问by gwinh

I am having trouble rendering a view in my controller. I am currently running Laravel 4 and below is my code. (BTW, I am still learning Laravel particularly the latest version that has not been released yet. I find it a bad idea to learn from the older versions because there seems to be a lot of changes for the current one.)

我在控制器中呈现视图时遇到问题。我目前正在运行 Laravel 4,以下是我的代码。(顺便说一句,我仍在学习 Laravel,尤其是尚未发布的最新版本。我发现从旧版本中学习是一个坏主意,因为当前版本似乎有很多变化。)

controllers/PluginsController.php

控制器/插件Controller.php

class PluginsController extends BaseController {
    public function index()
    {
        return View::make('plugins.index')->with(array('title'=>"The Index Page"));
    }

views/plugins/index.blade.php

意见/插件/index.blade.php

@layout('templates.master')

@section('header')
    <h1>The Header</h1>
@endsection

@section('content')
    testing the index.blade.php
@endsection


@section('footer')
    <div style="background:blue;">
        <h1>My Footer Goes Here</h1>
    </div>
@endsection

views/templates/master.blade.php

视图/模板/master.blade.php

 <!doctype>
 <html>
    <head>
        <meta charset="UTF-8" />
        @yield('meta_info')
        <title>{{$title}}</title>
        @yield('scripts')
    </head>
    <body>
        <div id="header">
            @yield('header')
        </div>

        <div id="wrapper">
            @yield('content')
        </div>

        <div id="footer">
            @yield('footer')
        </div>
    </body>
 </html>

回答by Miguel Borges

you must use @extendsinstead of @layout, and @stopinstead of @endsection

你必须使用@extends而不是@layout,而@stop不是@endsection

回答by gwinh

Using @extendsinstead of @layoutsolved my problem.

使用@extends而不是@layout解决了我的问题。