doujiao2014 2015-02-07 22:02
浏览 302
已采纳

Laravel 5 Form :: model(...)默认转义?

Maybe this is a simple thing that I'm missing, but in my laravel blade template I have something like:

{{ Form::model(....) }}
    ... my fields ...
{{ Form::close() }}

This results with escaped HTML so the form tag is actually printed to the screen. However, if I do:

{!! Form::model(....) !!}
    ... my fields ...
{!! Form::close() !!}

it works as expected. Do I always need to use the {!! ... !!} when outputting html? All the tutorials I've read up on just show using the normal convention of {{ Form::model(...) }} to open the form. Thanks for any advice! Using Laravel 5 fwiw.

  • 写回答

3条回答 默认 最新

  • dreamMyDream2014 2015-02-07 22:36
    关注

    That is correct.

    Laravel 4

    {{ ... }} for raw html
    {{{ ... }}} for escaping with htmlentities()

    Laravel 5

    {!! ... !!} for raw html
    {{{ ... }}} for explicitly escaped content
    {{ ... }} for the default behavior (which is escaped as well)


    If you don't like it you can change all 3 of those tags with these methods:

    Blade::setRawTags($openTag, $closeTag);
    Blade::setContentTags($openTag, $closeTag);
    Blade::setEscapedContentTags($openTag, $closeTag);
    

    To restore the way how Laravel 4 handled things, you can do this:

    Blade::setRawTags('{{', '}}');
    Blade::setEscapedContentTags('{{{', '}}}');
    
    本回答被题主选为最佳回答 , 对您是否有帮助呢?
    评论
查看更多回答(2条)

报告相同问题?

悬赏问题

  • ¥30 关于用python写支付宝扫码付异步通知收不到的问题
  • ¥50 vue组件中无法正确接收并处理axios请求
  • ¥15 隐藏系统界面pdf的打印、下载按钮
  • ¥15 MATLAB联合adams仿真卡死如何解决(代码模型无问题)
  • ¥15 基于pso参数优化的LightGBM分类模型
  • ¥15 安装Paddleocr时报错无法解决
  • ¥15 python中transformers可以正常下载,但是没有办法使用pipeline
  • ¥50 分布式追踪trace异常问题
  • ¥15 人在外地出差,速帮一点点
  • ¥15 如何使用canvas在图片上进行如下的标注,以下代码不起作用,如何修改