默认的rails XML构建器会转义所有HTML,例如:
atom_feed do |feed|
@stories.each do |story|
feed.entry story do |entry|
entry.title story.title
entry.content "foo"
end
end
end
将产生文字:
foo
而不是:foo
有没有办法指示XML构建器不转义XML?
结果你需要做
entry.content "foo", :type => "html"
虽然将它包装在CDATA中会阻止它工作.
entry.content "type" => "html" do entry.cdata!(post.content) end