如何将 html 标签包含到 laravel 即时消息中?

How to include html tags to laravel flash message?

有没有办法在即显消息中包含 html 标签。我有以下内容,但在 blade?

中呈现时标签被转义
 flash()->success('Confirmation email sent to <strong>' . $user->email . '</strong>');

您将不得不使用 blade 的非转义语法

{!! $flashData !!}  // unescaped variable

而不是:

{{ $flashData }}  // escaped variable

转义语法最好默认使用,因为它可以阻止行为不当的用户提供 <script> 标签和 javascript 代码作为您应用的输入。如果 html 标签和 javascript 没有被删除,这可能是一个安全问题。所以我会非常小心地转义数据,除非你 100% 确定它是安全的。

此外,只是想一想:为什么需要闪存数据中的 html?为什么不能直接发送 $user->email ,让视图自行决定如何渲染它。将 html 标记保留在您的视图中 - 这样更简洁。

查看文档 http://laravel.com/docs/5.1/blade#displaying-data 搜索 "Displaying Unescaped Data"