A utility method for escaping HTML tag
characters. This method is also aliased as h.
In your ERB templates, use this method to escape
any unsafe content. For example:
<%=h @person.name %>
puts html_escape('is a > 0 & a < 10?')
# =>isa>0&a<10?
# File activesupport/lib/active_support/core_ext/string/output_safety.rb, line 20
def html_escape(s)
s = s.to_s
if s.html_safe?
s
else
s.gsub(HTML_ESCAPE_REGEXP, HTML_ESCAPE).html_safe
end
end