【问题标题】:Laravel 4 Blade Template Engine not workingLaravel 4 Blade 模板引擎不工作
【发布时间】:2013-06-07 16:50:26
【问题描述】:

我正在将一个刚开始的 Laravel 3 项目转换为 Laravel 4,并且对刀片模板引擎没有太多乐趣。我知道其中一些内容已更改,但在尝试运行我的网站主页时仍然收到 500 内部服务器错误。它看起来像一些 index.blade.php 文件加载,但 default.blade.php 没有。这很奇怪,因为我在其他页面上仍然有错误,但似乎 default.blade.php 文件至少会加载,即使它没有显示。

default.blade.php

<html>
<head>
     {{ HTML::style('css/.css'); }}
     {{ HTML::style('css/.css'); }} 
     {{ HTML::style('css/style.css'); }}
     {{ HTML::script('js/jquery.js'); }}
</head>
@yield('content')
<footer>
</footer>
</html>

index.blade.php

@extends('default')

@section('content')
<body>

</body>
@stop

HomeController.php

    public function showHome()
{
    return View::make('home@index');
}

route.php

    Route::get('/', function()
{
    return View::make('home.index');
});

【问题讨论】:

  • 您的默认文件保存在哪里?什么目录?
  • 它在 /views/ 文件夹中
  • 附带问题...这 2 个 css 文件应该是空的吗?还是stackoverflow上的错字?
  • 还有你为什么要返回两次视图?
  • 如果将 route.php 更改为 View::make('default'); 会发生什么并取出产量('内容')。默认显示吗??

标签: routes laravel laravel-4


【解决方案1】:

选项 1

routes.php

Route::get('/', 'HomeController@showHome'); //delete everything else

HomeController.php

public function showHome()
{
  return View::make('home.index');
}

选项 2

再次尝试运行您的代码;它应该可以工作,因为您没有注册控制器,因此它没有运行。无论如何,如果没有,只需删除 HomeController.php。您的 routes.php 很好(如果您不使用控制器)

【讨论】:

    猜你喜欢
    • 1970-01-01
    • 2013-07-01
    • 1970-01-01
    • 2020-03-05
    • 2013-07-21
    • 2020-10-16
    • 2012-12-26
    • 2017-03-09
    • 1970-01-01
    相关资源
    最近更新 更多