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
949 950 951 |
# File 'lib/erb.rb', line 949 def html_escape(s) CGI.escapeHTML(s.to_s) end |
.html_escape(s) ⇒ Object
946 947 948 |
# File 'lib/erb.rb', line 946 def html_escape(s) CGI.escapeHTML(s.to_s) end |
.u ⇒ Object
970 971 972 973 974 |
# File 'lib/erb.rb', line 970 def url_encode(s) s.to_s.b.gsub(/[^a-zA-Z0-9_\-.]/n) { |m| sprintf("%%%02X", m.unpack("C")[0]) } end |
.url_encode(s) ⇒ Object
965 966 967 968 969 |
# File 'lib/erb.rb', line 965 def url_encode(s) s.to_s.b.gsub(/[^a-zA-Z0-9_\-.]/n) { |m| sprintf("%%%02X", m.unpack("C")[0]) } end |