我尝试使用数据库中的内容渲染html标记。
它是一堆带有简单<a>
标记的文字。
这是它在数据库字段中的设置方式。数据库字段类型为varchar(200)
,排序规则为utf8_unicode_ci
这是该字段的值:
blablabla <a href="mailto:info@atmox.nl">info@atmox.nl</a> blablabla
我尝试仅使用{!! !!}
刀片语法,但它只是将标记呈现为纯文本。最后我尝试了html_entity_decode
和htmlspecialchars_decode
函数,但它的结果是一样的。纯文本。
这是html部分
<p>{!! $baan->descriptiond !!}</p>
答案 0 :(得分:1)
尝试使用htmlentities($baan->descriptiond)
,html_entity_decode($string)
对您的数据进行渲染,然后使用{{$ baan-&gt; descriptiond}}来渲染html。
OR
只需使用普通的laravel刀片:
{{$baan->descriptiond}}
答案 1 :(得分:1)
你真的应该能够做到这一点:
<style>
.apm-center{
vertical-align:middle;
}
.apm-top{
vertical-align:top;
}
</style>
<div class="celwidget aplus-module module-4">
<div class="a-expander-collapsed-height a-row a-expander-container a-expander-partial-collapse-container" aria-live="polite" data-a-expander-name="aplus-module-expander" data-a-expander-collapsed-height="700">
<div class="a-expander-content a-expander-partial-collapse-content" aria-expanded="false">
<div class="aplus-module-wrapper">
<div class="apm-spacing">
<div class="apm-floatleft">
<h3 class="a-spacing-small a-color-secondary">Sea of Thieves offers something for everyone, no matter how they like to play:</h3>
<div class="a-spacing-extra-large">
<div class="apm-spacing">
<table class="apm-fixed-width a-spacing-mini apm-fourthcol-table">
<tbody>
<tr>
<th class="apm-center">
<div class="apm-fourthcol">
<img src="https://i.imgur.com/UMdg1zv.png" alt="" width="220" />
</div>
</th>
<th class="apm-center">
<div class="apm-fourthcol">
<img src="https://i.imgur.com/o6iR7pN.png" alt="" width="220" />
</div>
</th>
<th class="apm-center">
<div class="apm-fourthcol">
<img src="https://i.imgur.com/KOmLejc.png" alt="" width="220" />
</div>
</th>
<th class="apm-center">
<div class="apm-fourthcol">
<img src="https://i.imgur.com/fJh5o2J.png" alt="" width="220" />
</div>
</th>
</tr>
<tr>
<td width="220" class="apm-top">
<div class="apm-fourthcol">
<h4 class="a-spacing-mini">A world of exploration</h4>
<p class="a-size-small">set sail upon a vast, open ocean, venturing into new regions and discovering the secrets of unspoiled islands and sunken ships. Hunt for treasure by following maps and untangling riddles, and learn to expect the unexpected...</p>
</div>
</td>
<td width="220" class="apm-top">
<div class="apm-fourthcol">
<h4 class="a-spacing-mini">A world of excitement</h4>
<p class="a-size-small">engage in ship-to-ship crew battles with cannon, pistol and cutlass, pursuing rival ships through raging storms. Sail in pursuit of deadly bounties or ferry cargo through hostile waters. Clash with the skeletal remains of cursed
former pirates and beware undersea menaces that lurk beneath the waves!</p>
</div>
</td>
<td width="220" class="apm-top">
<div class="apm-fourthcol">
<h4 class="a-spacing-mini">A world we sail together</h4>
<p class="a-size-small">whether you’re playing alongside friends, matchmaking to find a crew or setting out as a ‘lone wolf’ pirate, you’ll have hilarious, memorable encounters in a world where every sail on the horizon is a crew of real players.</p>
</div>
</td>
<td width="220" class="apm-top">
<div class="apm-fourthcol">
<h4 class="a-spacing-mini">A world of achievement</h4>
<p class="a-size-small">on your quest to become a pirate legend you’ll amass loot, build a reputation and customize your ship (and yourself) with your hard-earned rewards.</p>
</div>
</td>
</tr>
</tbody>
</table>
</div>
</div>
</div>
</div>
</div>
</div>
</div>
</div>
假设<p>{!! html_entity_decode($baan->descriptiond) !!}</p>
类似于:
$baan->descriptiond
答案 2 :(得分:1)
你需要这样做
{!! $text !!}
执行{{}} 时,字符串将自动转义
对于laravel 5
{!!html_entity_decode($text)!!}