ruby-on-rails – 在Rails中同时使用simple_format和html_safe
发布时间:2020-12-16 22:18:14 所属栏目:百科 来源:网络整理
导读:在@ post.content中,我想要 1.simple_format,所以内容会有不同的行,而不是单行,没有中断 2.html_safe,因此用户可以粘贴一些 embed像youtubes这样的视频链接 可以使用%= simple_format @ post.content%和%= @ post.content.html_safe%分别 但是当我们一起
在@ post.content中,我想要
1.simple_format,所以内容会有不同的行,而不是单行,没有中断 2.html_safe,因此用户可以粘贴一些< embed>像youtubes这样的视频链接 可以使用<%= simple_format @ post.content%>和<%= @ post.content.html_safe%>分别 但是当我们一起使用它们时:<%= simple_format @ post.content.html_safe%>,html_safe不起作用,因此< embed>视频不显示 你能告诉我如何在同一时间启用< embed> code和simple_format?还是有其他解决方案来显示@ post.content?谢谢!!! 解决方法
我会告诉simple_format不要清理我的内容:
simple_format(@post.content,{},:sanitize => false) (编辑:李大同) 【声明】本站内容均来自网络,其相关言论仅代表作者个人观点,不代表本站立场。若无意侵犯到您的权利,请及时与联系站长删除相关内容! |