3刀片模板不起作用

3刀片模板不起作用

本文介绍了Laravel 3刀片模板不起作用的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

我正在学习Laravel 3,但是Blade模板不起作用.我的代码似乎正确,但是显示的只是@layout('master').页面源也仅包含此文本.application\views\home\index.blade.php内容:

I'm learning Laravel 3, but Blade template is not working. My code seems correct, but all it displays is @layout('master'). Pages source also contains this text only.application\views\home\index.blade.php contents:

@layout('master')

@section('main')
    {{ $greeting }}
@endsection

application\views\master.blade.php内容:

<!doctype html>
<html>
    <head>
    <meta charset="utf-8">
    <title>Hello world!</title>
</head>
<body>
    <div id="container">
        @yield('main')
    </div>
</body>
</html>

routes.php中的

Route::get('/, home', function()
{
$greeting = "Hello world";
return View::make('home.index')->with('greeting',$greeting);
});

什么会导致刀片不工作?我也尝试过Laravel 4,并将@layout更改为@extends,将@endsection更改为@stop,但情况相同.我只得到@extends('master').

What can cause blade not to work? I tried Laravel 4 also, and changed @layout to @extends, @endsection to @stop but same situation. I get only @extends('master').

推荐答案

只需删除代码前的每个空格或EOL,CR,LF,Enter,\ n(或其他)即可.在Laravel 4中,同样的问题,我遵循了快速启动的步骤,查看我要下一行.

Just remove every space or EOL, CR, LF, Enter, \n (or whatever) before your code.Same issue in Laravel 4, I followed the quick start the step where you create a view I leave a new line.

-New line here, and it brokes-
@extends('layout')

@section('content')
    Users!
@stop

再次删除@extends('layout')之前的所有内容,对我有用!

Again remove anything before @extends('layout') and it works for me!!

这篇关于Laravel 3刀片模板不起作用的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持!

08-19 02:22