Module: Simply::Escaping
- Included in:
- HTMLBuilder
- Defined in:
- lib/simply/escaping.rb
Instance Method Summary collapse
-
#html_escape(s) ⇒ Object
(also: #h)
A utility method for escaping HTML tag characters in s.
Instance Method Details
#html_escape(s) ⇒ Object Also known as: h
A utility method for escaping HTML tag characters in s.
Taken from ERB::Util
puts html_escape(“is a > 0 & a < 10?”)
Generates
is a > 0 & a < 10?
14 15 16 |
# File 'lib/simply/escaping.rb', line 14 def html_escape(s) s.to_s.gsub(/&/, "&").gsub(/\"/, """).gsub(/>/, ">").gsub(/</, "<") end |