Skip to content

End of Life Ruby 3.0 has reached end of life and gets no more fixes. Switch to Ruby 4.0 →

instance 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 .url_encode .u also in 3.1