Reputation: 191
I have this string:
'<div class="md"><p><a href="http://www.google.com/">Foo</a></p> </div>'
which I'm trying to display as:
Foo
So I'm trying to convert the original string to raw HTML.
I've tried:
raw '<div class="md"><p><a href="http://www.google.com/">Foo</a></p> </div>'
which converts the entity to normal HTML but displays it as a string:
<div class="md"><p><a href="http://www.google.com/">Foo</a></p> </div>
I've also tried html_safe and html_safe.html_safe but those are giving me the same results.
So how do I convert a string containing HTML entities to raw HTML to be rendered in Rails?
Thanks
Upvotes: 2
Views: 1348
Reputation: 1230
Try something like this:
CGI.unescapeHTML('<div class="md"><p><a href="http://www.google.com/">Foo</a></p> </div>').html_safe
Upvotes: 7