I am trying to decode some HTML entities, such as '<'
becoming '<'
.
I have an old gem (html_helpers) but it seems to have been abandoned twice.
Any recommendations? I will need to use it in a model.
I am trying to decode some HTML entities, such as '&lt;'
becoming '<'
.
I have an old gem (html_helpers) but it seems to have been abandoned twice.
Any recommendations? I will need to use it in a model.
HTMLEntities can do it:
If you don't want to add a new dependency just to do this (like
HTMLEntities
) and you're already usingHpricot
, it can both escape and unescape for you. It handles much more thanCGI
:I think Nokogiri gem is also a good choice. It is very stable and has a huge contributing community.
Samples:
or
To decode characters in Rails use:
So,
would output
You can use
htmlascii
gem: