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">&lt;![CDATA[ &amp;lt;p&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/
精彩评论