Laravel 4刀片模板导致FatalErrorException? [英] Laravel 4 blade templates causing FatalErrorException?

查看:65
本文介绍了Laravel 4刀片模板导致FatalErrorException?的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

当尝试使用刀片模板来实现简单的页面布局时,出现了无法解释的FatalErrorException.我不确定这是我做错了还是Laravel.我正在遵循有关模板化的L4文档上的教程,而我的代码似乎也遵循它.这是我的代码.

I'm getting an unexplained FatalErrorException when trying to implement a simple page layout using blade templating. I'm not sure if it's something I'm doing wrong or Laravel is. I'm following the tutorial on L4's documentation about Templating and my code seems to follow it. Here's my code.

app/routes.php:

app/routes.php:

<?php
Route::get('/', 'HomeController@showWelcome');

app/views/home/welcome.blade.php:

app/views/home/welcome.blade.php:

@extends('layouts.default')
@section('content')
  <h1>Hello World!</h1>
@stop

app/views/layouts/default.blade.php:

app/views/layouts/default.blade.php:

<!doctype html>
<html>
  <head>
    <title>The Big Bad Barn (2013)</title>
  </head>
  <body>
    <div>
      @yield('content')
    </div>
  </body>
</html>

app/controllers/HomeController.php:

app/controllers/HomeController.php:

<?php
class HomeController extends BaseController {
  protected $layout = 'layouts.default';
  public function showWelcome()
  {
    $this->layout->content = View::make('home.welcome');
  }
}

Laravel仅仅抛出FatalErrorException.输出错误页面显示语法错误,意外的'?'".在storage/views目录内生成的文件刀片具有PHP,其中

Laravel just throws a FatalErrorException. The output error page says "syntax error, unexpected '?'". The file blade is generating inside the storage/views directory has PHP where the

<?php echo $__env->make('layouts.default')

<?php $__env->startSection('content', array_except(get_defined_vars(), array('__data', '__path')))->render(); ?>; ?>
<h1>Hello World!</h1>
<?php $__env->stopSection(); ?>

推荐答案

昨天我遇到了与您相同的问题,但是其他答案并没有解决我的问题.您可能已经弄清楚了,但是也许这篇文章阻止了其他人像我那样花很多时间弄清楚哪里出了问题,而这却是一件很小的事(但令人沮丧!).

Yesterday I encountered the same problem you did, however the other answers didn't fix my problem. You've probably figured it out already, but maybe this post prevents others from spending as much time as I did figuring out what is wrong while it's such a small (but frustrating!) thing.

我使用Notepad ++作为文本编辑器,出于某种奇怪的原因,它决定使用"MAC格式"作为行尾(EOL)格式.显然,Blade框架无法解决这一问题.使用转换功能(在notepad ++中:编辑-> EOL转换)转换为Windows格式,即可正常使用..

I'm using Notepad++ as text-editor and for some strange reason it had decided to use "MAC format" as the End-Of-Line (EOL) format. Apparently the Blade framework can't cope with that. Use the conversion function (in notepad++ : Edit -> EOL Conversion) to convert to Windows Format and it will work just fine..

这篇关于Laravel 4刀片模板导致FatalErrorException?的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

查看全文
登录 关闭
扫码关注1秒登录
发送“验证码”获取 | 15天全站免登陆