I\'m working with Ruby on Rails, Is there a way to strip html
from a string using sanitize or equal method and keep only text inside value attribute on input ta
I've used the Loofah library, as it is suitable for both HTML and XML (both documents and string fragments). It is the engine behind the html sanitizer gem. I'm simply pasting the code example to show how simple it is to use.
Loofah Gem
unsafe_html = "ohai! div is safe "
doc = Loofah.fragment(unsafe_html).scrub!(:strip)
doc.to_s # => "ohai! div is safe "
doc.text # => "ohai! div is safe "