Laravel 4 blade templates causing FatalErrorException?

时光总嘲笑我的痴心妄想 提交于 2019-12-04 07:20:07

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.

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..

Your controller should be just returning View::make("home.welcome") instead of attaching it to the layout.

The welcome view then calls the layout so the controller is only concerned about the body template in this case.

Edit for showing example controller:

class HomeController extends BaseController {
  public function showWelcome()
  {
    return View::make('home.welcome');
  }
}

Eric already gave the right answer, I just wanted to add that if you want to use

protected $layout = 'layouts.default';

in your HomeController, then leave showWelcome action intact and remove this line

@extends('layouts.default')

from welcome.blade.php file. That should work too.

Regards, Vlad

易学教程内所有资源均来自网络或用户发布的内容,如有违反法律规定的内容欢迎反馈
该文章没有解决你所遇到的问题?点击提问,说说你的问题,让更多的人一起探讨吧!