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
1005 1006 1007 |
# File 'lib/erb.rb', line 1005 def html_escape(s) CGI.escapeHTML(s.to_s) end |
.html_escape(s) ⇒ Object
1002 1003 1004 |
# File 'lib/erb.rb', line 1002 def html_escape(s) CGI.escapeHTML(s.to_s) end |
.u ⇒ Object
1026 1027 1028 1029 1030 |
# File 'lib/erb.rb', line 1026 def url_encode(s) s.to_s.b.gsub(/[^a-zA-Z0-9_\-.~]/n) { |m| sprintf("%%%02X", m.unpack1("C")) } end |
.url_encode(s) ⇒ Object
1021 1022 1023 1024 1025 |
# File 'lib/erb.rb', line 1021 def url_encode(s) s.to_s.b.gsub(/[^a-zA-Z0-9_\-.~]/n) { |m| sprintf("%%%02X", m.unpack1("C")) } end |