php laravel刀片模板未渲染 [英] php laravel blade template not rendering
问题描述
我正在尝试使用Laravel和Twitter引导程序来设置基本页面.我安装了Laravel并获得了通用的您在这里"或w/e图像,因此看起来很有光泽.对于twitter bootstrap,我在/public文件夹中的/resources/js,/resources/css和/resources/img下添加了twitter bootstrap文件.
I am attempting to setup a basic page using Laravel and twitter bootstrap. I installed Laravel and got the generic "you're here" or w/e image so that seems shiny. For twitter bootstrap, I added in my /public folder the twitter bootstrap files under /resources/js, /resources/css, and /resources/img.
所以现在我想为我的视图创建一个模板,基本上在我的head标签中输出twitter bootstrap .css文件,而在我关闭之前就输出bootstrap.min.js和jquery.js脚本身体标签.
So now I'm trying to make a template for my views, where basically the twitter bootstrap .css files are output in my head tag and the bootstrap.min.js and jquery.js script includes are output just before my closing body tag.
这就是我设置的内容:
laravel/app/routes.php
Route::get('/', function()
{
return View::make('hello');
});
laravel/app/views/hello.php
@extends('layouts.master')
@section('content')
<p>This is my body content.</p>
@stop
laravel/app/views/layouts/master.blade.php
<html>
<head>
@section('head')
<meta name="viewport" content="width=device-width, initial-scale=1.0">
<link href="/resources/css/bootstrap.min.css" rel="stylesheet" media="screen">
@show
</head>
<body>
<div class="container">
@yield('content')
</div>
@section('footer_scripts')
<script src="http://code.jquery.com/jquery.js"></script>
<script src="/resources/js/bootstrap.min.js"></script>
@show
</body>
</html>
但是刀片模板似乎没有渲染.这是我得到的输出:
But it the blade template doesn't seem to be rendering. This is the output I get:
@extends('layouts.master') @section('content')
This is my body content.
@stop
这就是页面和视图源中的外观.不包含html标签或脚本;没有什么.我必须缺少一些基本的知识,并且尝试浏览Laravel文档,但似乎无法弄清楚自己在做错什么..有人可以向我指出正确的方向吗?
That's how it looks on-page as well as in the view-source. No html tag or script includes; nothing. I must be missing something basic, and I've tried looking through the Laravel docs, but I can't seem to figure out what I'm doing wrong.. can someone point me in the right direction?
推荐答案
要使用刀片模板,您必须在文件名中包含 .blade
,例如,您的文件名应为
To use a blade template you must have the .blade
in file name, for example in your case it should be
hello.blade.php
否则,它将不会渲染.在 Laravel网站上了解更多信息.这是我的一个测试项目(index.blade.php)中的一个示例,因为您有错字 @extends('layout.master')
,应该是这样的
Otherwise, it won't render. Read more on Laravel Site.
Here is an example from one of my testing projects (index.blade.php), since you had a typo @extends('layout.master')
it should be something like this
@extends('layouts.master')
@section('content')
This is a sample of laravel 4 using blade template engine.
This is home page using HomeController and home.blade template.
@stop
这篇关于php laravel刀片模板未渲染的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!