【发布时间】:2013-04-23 11:55:22
【问题描述】:
在@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(@post.content).html_safe怎么样?这将在 simple_format 的输出上调用 html safe,而不是在 post.content 的 html_safe 版本中“简单格式化”。 -
嗯....还是不行....
-
你能显示
@post.content的输出吗? -
与simple_format @post.content.html_safe 相同,不显示
<embed>代码。 apneadiving 的答案是有效的