Module ERB::Util
In: lib/erb.rb

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

Methods

h   html_escape   u   url_encode  

Public Instance methods

h(s)

Alias for html_escape

A utility method for escaping HTML tag characters in s.

  require "erb"
  include ERB::Util

  puts html_escape("is a > 0 & a < 10?")

Generates

  is a &gt; 0 &amp; a &lt; 10?
u(s)

Alias for url_encode

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

[Validate]

ruby-doc.org is hosted and maintained by James Britt and Happy Camper Studios, a Ruby application development company in Phoenix, Arizona. The site was created in 2002 as part of the Ruby Documentation Project to promote the Ruby language and to help other Ruby hackers.

Documentation content on ruby-doc.org is provided by remarkable members of the Ruby community.

For more information on the Ruby programming language, visit ruby-lang.org.

Want to help improve Ruby's API docs? See Ruby Documentation Guidelines.