开发者

No HTML tag escaping in Rails XML file

I want to display some HTML in a XML view file (RSS) in rails:

开发者_运维百科
# ...
xml.description raw("<![CDATA[ "+raw(news.content(@language).body)+"]]>")
# ...

This generates the following ...

<description type="html">&amp;lt;![CDATA[ &amp;amp;lt;p&amp;amp;gt; ...

Any ideas?


After messing around with #raw and #html_safe, I found this to be working:

# ...
xml.description do
  xml.cdata! news.content(@language).body
end
# ...


Hmm. html_safe should work. Maybe this will help you? http://yehudakatz.com/2010/02/01/safebuffers-and-rails-3-0/

0

上一篇:

下一篇:

精彩评论

暂无评论...
验证码 换一张
取 消

最新问答

问答排行榜