f00860
f00860

Reputation: 3576

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?

Upvotes: 1

Views: 1952

Answers (2)

Benjamin Quorning
Benjamin Quorning

Reputation: 121

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

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

Upvotes: 4

David Sulc
David Sulc

Reputation: 25994

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

Upvotes: 0

Related Questions