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
914 915 916 |
# File 'lib/erb.rb', line 914 def html_escape(s) s.to_s.gsub(/&/, "&").gsub(/\"/, """).gsub(/>/, ">").gsub(/</, "<") end |
.html_escape(s) ⇒ Object
911 912 913 |
# File 'lib/erb.rb', line 911 def html_escape(s) s.to_s.gsub(/&/, "&").gsub(/\"/, """).gsub(/>/, ">").gsub(/</, "<") end |
.u ⇒ Object
935 936 937 938 939 |
# File 'lib/erb.rb', line 935 def url_encode(s) s.to_s.dup.force_encoding("ASCII-8BIT").gsub(/[^a-zA-Z0-9_\-.]/n) { sprintf("%%%02X", $&.unpack("C")[0]) } end |
.url_encode(s) ⇒ Object
930 931 932 933 934 |
# File 'lib/erb.rb', line 930 def url_encode(s) s.to_s.dup.force_encoding("ASCII-8BIT").gsub(/[^a-zA-Z0-9_\-.]/n) { sprintf("%%%02X", $&.unpack("C")[0]) } end |