繁体   English   中英

Laravel不渲染HTML

[英]Laravel not rendering html

我尝试使用数据库中的内容来呈现html标记。 这是一堆带有简单<a>标记的文本。

这是在数据库字段中设置的方式。 数据库字段类型为varchar(200)

排序规则是utf8_unicode_ci

这是该字段的值:

blablabla &lt;a href=&quot;mailto:info@atmox.nl&quot;&gt;info@atmox.nl&lt;/a&gt; blablabla

我尝试仅使用{!! !!} {!! !!}刀片语法,但只会将标记呈现为纯文本。 最终,我尝试了html_entity_decodehtmlspecialchars_decode函数,但是结果是相同的。 纯文本。

这是html部分

<p>{!! $baan->descriptiond !!}</p>

尝试在数据上使用htmlentities($baan->descriptiond)htmlentities($baan->descriptiond) html_entity_decode($string)呈现,然后使用{{$ baan-> descriptiond}}呈现html。

要么

只需使用普通的laravel刀片即可:

{{$baan->descriptiond}}

您确实应该能够做到这一点:

<p>{!! html_entity_decode($baan->descriptiond) !!}</p>

假设$baan->descriptiond类似于:

&lt;a href=&quot;mailto:info@atmox.nl&quot;&gt;info@atmox.nl&lt;/a&gt;

你需要这样做

{!! $text !!}

执行{{}}时字符串将自动转义

对于laravel 5

{!!html_entity_decode($text)!!}

暂无
暂无

声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM