Module: ERB::Util
- Defined in:
- lib/missing/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
646 647 648 |
# File 'lib/missing/erb.rb', line 646 def html_escape(s) s.to_s.gsub(/&/, "&").gsub(/\"/, """).gsub(/>/, ">").gsub(/</, "<") end |
.html_escape(s) ⇒ Object
643 644 645 |
# File 'lib/missing/erb.rb', line 643 def html_escape(s) s.to_s.gsub(/&/, "&").gsub(/\"/, """).gsub(/>/, ">").gsub(/</, "<") end |
.u ⇒ Object
667 668 669 670 671 |
# File 'lib/missing/erb.rb', line 667 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
662 663 664 665 666 |
# File 'lib/missing/erb.rb', line 662 def url_encode(s) s.to_s.dup.force_encoding("ASCII-8BIT").gsub(/[^a-zA-Z0-9_\-.]/n) { sprintf("%%%02X", $&.unpack("C")[0]) } end |