End of Life Ruby 3.1 has reached end of life and gets no more fixes. Switch to Ruby 4.0 →
class method
ERB::Util.h
h(s)
lib/erb.rb
View on GitHub ↗
# File tmp/rubies/ruby-3.1.3/lib/erb.rb, line 1001
def html_escape(s)
CGI.escapeHTML(s.to_s)
end
Alias of .html_escape
A utility method for escaping HTML tag characters in s.
Example
require "erb" include ERB::Util puts html_escape("is a > 0 & a < 10?")
Generates
is a > 0 & a < 10?