laravel 5 blade 模板打印 html 作为文本

laravel 5 blade template prints html as text

我在数据库中有 <p><strong>Some Body Lement&nbsp;Some Body Lement</strong></p>。我想在 blade 中打印为 html。但它打印为文本

在我的 blade 我有

@foreach( $articles as $article )
    <div class="recommended-info"><h3>{{ $article['title'] }}</h3></div>
    {{ $article['body'] }}
@endforeach

如果不想转义HTML,则需要使用{!! !!}语法。示例:

@foreach( $articles as $article )
    <div class="recommended-info"><h3>{{ $article['title'] }}</h3></div>
    {!! $article['body'] !!}
@endforeach

来源:http://laravel.com/docs/5.1/blade

部分:“显示未转义的数据”。

By default, Blade {{ }} statements are automatically sent through PHP's htmlentities function to prevent XSS attacks.

Note: Be very careful when echoing content that is supplied by users of your application. Always use the double curly brace syntax to escape any HTML entities in the content.