Module: ERB::Util

Includes:
Escape
Defined in:
lib/erb/util.rb

Overview

– ERB::Util

A utility module for conversion routines, often handy in HTML generation.

Class Method Summary collapse

Class Method Details

.hObject



# File 'lib/erb/util.rb', line 42

.html_escapeObject

.uObject

A utility method for encoding the String s as a URL.

require "erb"
include ERB::Util

puts url_encode("Programming Ruby:  The Pragmatic Programmer's Guide")

Generates

Programming%20Ruby%3A%20%20The%20Pragmatic%20Programmer%27s%20Guide


60
61
62
# File 'lib/erb/util.rb', line 60

def url_encode(s)
  CGI.escapeURIComponent(s.to_s)
end

.url_encode(s) ⇒ Object

A utility method for encoding the String s as a URL.

require "erb"
include ERB::Util

puts url_encode("Programming Ruby:  The Pragmatic Programmer's Guide")

Generates

Programming%20Ruby%3A%20%20The%20Pragmatic%20Programmer%27s%20Guide


57
58
59
# File 'lib/erb/util.rb', line 57

def url_encode(s)
  CGI.escapeURIComponent(s.to_s)
end