問題描述
也許這是我遺漏的一件簡單的事情,但在我的 laravel 刀片模板中,我有類似的東西:
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() }}
這會產(chǎn)生轉(zhuǎn)義的 HTML,因此表單標(biāo)簽實際上會打印到屏幕上.但是,如果我這樣做:
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() !!}
它按預(yù)期工作.我是否總是需要使用 {!!... !!}
輸出 html 時?我讀過的所有教程都只是使用 {{ Form::model(...) }}
的常規(guī)約定來打開表單.感謝您的任何建議!使用 Laravel 5 fwiw.
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.
推薦答案
正確.
{{ ... }}
用于原始 html{{{ ... }}}
用于使用 htmlentities()
{{ ... }}
for raw html
{{{ ... }}}
for escaping with htmlentities()
<代碼>{?。?.. !!} 用于原始 html{{{ ... }}}
用于顯式轉(zhuǎn)義的內(nèi)容{{ ... }}
用于默認(rèn)行為(也被轉(zhuǎn)義)
{!! ... !!}
for raw html
{{{ ... }}}
for explicitly escaped content
{{ ... }}
for the default behavior (which is escaped as well)
如果您不喜歡它,您可以使用以下方法更改所有 3 個標(biāo)簽:
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);
要恢復(fù) Laravel 4 處理事物的方式,您可以這樣做:
To restore the way how Laravel 4 handled things, you can do this:
Blade::setRawTags('{{', '}}');
Blade::setEscapedContentTags('{{{', '}}}');
這篇關(guān)于Laravel 5 Form::model(...) 默認(rèn)轉(zhuǎn)義?的文章就介紹到這了,希望我們推薦的答案對大家有所幫助,也希望大家多多支持html5模板網(wǎng)!