module ERB::Util
def html_escape(s)
puts html_escape("is a > 0 & a < 10?")
==== Example:
<%=h @person.name %>
In your ERB templates, use this method to escape any unsafe content. For example:
This method is also aliased as h.
A utility method for escaping HTML tag characters.
def html_escape(s) s = s.to_s if s.html_safe? s else s.encode(s.encoding, :xml => :attr)[1...-1].html_safe end end