123456789_123456789_123456789_123456789_123456789_

Module: ERB::Util

Relationships & Source Files
Super Chains via Extension / Inclusion / Inheritance
Instance Chain:
self, Escape
Defined in: lib/erb/util.rb

Class Method Summary

Instance Method Summary

Escape - Included

#html_escape

ERB::Util.html_escape does not allocate a new string when nothing needs to be escaped.

Class Method Details

.h(s) (mod_func)

Alias for Escape#html_escape.

[ GitHub ]

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

alias h html_escape

.u(s) (mod_func)

Alias for #url_encode.

[ GitHub ]

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

alias u url_encode

.url_encode(s) (mod_func) Also known as: #u

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
[ GitHub ]

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

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