Skip to content

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)

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 &gt; 0 &amp; a &lt; 10?
See also .html_escape #h .u also in 3.0