开发者

No HTML tag escaping in Rails XML file

开发者 https://www.devze.com 2023-01-27 02:59 出处:网络
I want to display some HTML in a XML view file (RSS) in rails:开发者_运维百科 # ... xml.description raw(\"<![CDATA[ \"+raw(news.content(@language).body)+\"]]>\")

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

精彩评论

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