Laravel 5.0-刀片模板错误 [英] Laravel 5.0 - Blade Template Errors
问题描述
只是在玩Laravel 5,并且在使用Blade模板语法时遇到了困难.看来我所有的特殊字符都已被转义.我的设置有问题吗?
Just playing about with Laravel 5, and am having difficulties using the Blade templating syntax. It appears that all my special characters are being escaped. Have I something wrong with my setup?
仅显示我的设置,我已经在config/app.php
中添加了以下内容:
Just to show my setup, I have added the following to config/app.php
:
别名:'Form' => 'Illuminate\Html\FormFacade', 'Html' => 'Illuminate\Html\HtmlFacade'
服务提供商:'Illuminate\Html\HtmlServiceProvider'
Aliases: 'Form' => 'Illuminate\Html\FormFacade', 'Html' => 'Illuminate\Html\HtmlFacade'
Service Providers: 'Illuminate\Html\HtmlServiceProvider'
现在这是我的刀片视图:
Now here's my blade view:
@extends('layout')
@section('content')
{{ Form::open() }}
{{ Form::close() }}
@stop
这是浏览器中的输出:
<form method="POST" action="http://test.app:8000/categories/create" accept-charset="UTF-8"><input name="_token" type="hidden" value="m4RdpqdbbqQ2F7iwfDkSDKTzEmaBGNvpJbj5LnqE"> </form>
这是view-source的输出:
And here is the output from view-source:
<!doctype HTML>
<html>
<head>
<meta http-equiv="Content-Type" content="text/html; charset=UTF-8" />
<title>My Site</title>
</head>
<body>
<header></header>
<content>
<form method="POST" action="http://test.app:8000/categories/create" accept-charset="UTF-8"><input name="_token" type="hidden" value="m4RdpqdbbqQ2F7iwfDkSDKTzEmaBGNvpJbj5LnqE">
</form>
</content>
</body>
</html>
推荐答案
在 Laravel 5 ,{{ }}
将自动转义.现在您需要使用的是{!! !!}
.
In Laravel 5, {{ }}
will auto escape. What you need to use now is {!! !!}
.
{!! Form::open() !!}
{!! Form::close() !!}
More read about the change can be seen on https://laracasts.com/discuss/channels/general-discussion/new-blade-tag-for-unescaped-data-thoughts (thanks to @user1960364).
这篇关于Laravel 5.0-刀片模板错误的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!