Monday, 15 July 2013

ruby on rails - Converting HTML Entity to Raw HTML -



ruby on rails - Converting HTML Entity to Raw HTML -

i have string:

'<div class="md"><p><a href="http://www.google.com/">foo</a></p> </div>'

which i'm trying display as:

foo

so i'm trying convert original string raw html.

i've tried:

raw '<div class="md"><p><a href="http://www.google.com/">foo</a></p> </div>'

which converts entity normal html displays string:

<div class="md"><p><a href="http://www.google.com/">foo</a></p> </div>

i've tried html_safe , html_safe.html_safe giving me same results.

so how convert string containing html entities raw html rendered in rails?

thanks

try this:

cgi.unescapehtml('&lt;div class="md"&gt;&lt;p&gt;&lt;a href="http://www.google.com/"&gt;foo&lt;/a&gt;&lt;/p&gt; &lt;/div&gt;').html_safe

html ruby-on-rails

No comments:

Post a Comment