I would like to return html content via jbuilder:
json.array!(@articles) do |article|
json.extract! article, :id, :title, :html_content
end
But it's returns escaped html:
{
"id": 2,
"title": "",
"html_content": "\u003cp\u003e\u003cimg alt=\"\" src=\"#\" /\u003e\u003c/p\u003e\r\n"
}
How can it return unescaped html?
You can use html_safe to disable the escape feature. Probably you run into some problems, because "
won't be escaped as well and it's in use to define a value in JSON.
I think the best approach is to encode it somehow, for example with base64
:
If you love us? You can donate to us via Paypal or buy me a coffee so we can maintain and grow! Thank you!
Donate Us With