biagidp
biagidp

Reputation: 2185

Render escaped html in Rails

I'm pulling product descriptions from Amazon and they arrive escaped, looking like <i>New York Times</i>

When I use h, raw or html_safe it shows up in my application as <i>New York Times</i>

But I'd really like it to show up as New York Times

Upvotes: 2

Views: 911

Answers (1)

Sean Huber
Sean Huber

Reputation: 3985

Try this:

<%= CGI.unescapeHTML("&lt;i&gt;New York Times&lt;/i&gt;").html_safe %>

The issue is that the string contains html that has already been escaped. So, you need to 'unesacpe' it first.

Upvotes: 2

Related Questions