Laravel 5.0-刀片模板错误 [英] Laravel 5.0 - Blade Template Errors

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

问题描述

只是在玩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>
    &lt;form method=&quot;POST&quot; action=&quot;http://test.app:8000/categories/create&quot; accept-charset=&quot;UTF-8&quot;&gt;&lt;input name=&quot;_token&quot; type=&quot;hidden&quot; value=&quot;m4RdpqdbbqQ2F7iwfDkSDKTzEmaBGNvpJbj5LnqE&quot;&gt;

    &lt;/form&gt;

</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屋!

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