instance method
html_escape
Ruby on Rails 2.2.3
Since v2.2.3 Last seen in v7.0.10Signature
html_escape(s)
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 %>
Example:
puts html_escape("is a > 0 & a < 10?") # => is a > 0 & a < 10?
Parameters
-
sreq
Source
# File actionpack/lib/action_view/template_handlers/erb.rb, line 17
def html_escape(s)
s.to_s.gsub(/[&"><]/) { |special| HTML_ESCAPE[special] }
end
Defined in actionpack/lib/action_view/template_handlers/erb.rb line 17
· View on GitHub
· Improve this page
· Find usages on GitHub
Defined in ERB::Util