I am trying to decode some HTML entities ('<' => '<'). I have found an old gem (http://github.com/tma/html_helpers/) but it seems to have been abandoned twice.
Any recommendations? (will need to use it in a model)
I am trying to decode some HTML entities ('<' => '<'). I have found an old gem (http://github.com/tma/html_helpers/) but it seems to have been abandoned twice.
Any recommendations? (will need to use it in a model)
To encode the characters, you can use CGI.escapeHTML
string = CGI.escapeHTML('test "escaping" <characters>')
To decode them, there is the CGI.unescapeHTML
CGI.unescapeHTML("test "unescaping" <characters>")
Of course, you need, before that, to include the cgi library.
require 'cgi'
And if you're in Rails, you don't need to use CGI to encode the string. There's the h method.
<%= h 'escaping <html>' %>