Module: ERB::Util
- Defined in:
- lib/erb.rb
Overview
A utility module for conversion routines, often handy in HTML generation.
Class Method Summary collapse
-
.h ⇒ Object
A utility method for escaping HTML tag characters in s.
-
.html_escape(s) ⇒ Object
A utility method for escaping HTML tag characters in s.
-
.u ⇒ Object
A utility method for encoding the String s as a URL.
-
.url_encode(s) ⇒ Object
A utility method for encoding the String s as a URL.
Class Method Details
.h ⇒ Object
785 786 787 |
# File 'lib/erb.rb', line 785 def html_escape(s) s.to_s.gsub(/&/, "&").gsub(/\"/, """).gsub(/>/, ">").gsub(/</, "<") end |
.html_escape(s) ⇒ Object
782 783 784 |
# File 'lib/erb.rb', line 782 def html_escape(s) s.to_s.gsub(/&/, "&").gsub(/\"/, """).gsub(/>/, ">").gsub(/</, "<") end |
.u ⇒ Object
804 805 806 |
# File 'lib/erb.rb', line 804 def url_encode(s) s.to_s.gsub(/[^a-zA-Z0-9_\-.]/n){ sprintf("%%%02X", $&.unpack("C")[0]) } end |
.url_encode(s) ⇒ Object
801 802 803 |
# File 'lib/erb.rb', line 801 def url_encode(s) s.to_s.gsub(/[^a-zA-Z0-9_\-.]/n){ sprintf("%%%02X", $&.unpack("C")[0]) } end |