Tri*_*rip 1 html ruby-on-rails redcloth
我保存了一个带有 html 标签的字符串。
=> "<p>hey man this is crazy g funk</p>\n<p>here i come with another crazy message from..</p>\n<p>dj eassssy d!@#!.</p>"
Run Code Online (Sandbox Code Playgroud)
您如何解析它以使其显示 HTML 标记所暗示的方式?
我试过:
= Post.text
=h Post.text
= RedCloth.new(Post.text).to_html
= Hpricot(Post.text)
Run Code Online (Sandbox Code Playgroud)
你想要这样做:
<%= raw Post.text %>
Run Code Online (Sandbox Code Playgroud)
或在哈姆尔
= raw Post.text
Run Code Online (Sandbox Code Playgroud)
原因是因为 Rails 转义了您的 html 并将转换<p>为<p>.
| 归档时间: |
|
| 查看次数: |
2043 次 |
| 最近记录: |