Erb rdoc wrong?



I am trying to use Erb to process a plain-text template. Following the
documentation at, I can’t
the first plain-text example to work. ruby 1.8.2 (2004-12-25)
[i686-linux]. Below[1] is the actual sample script which isn’t working
(it’s not finding the local variables when processing the template).
ideas what’s going on here? Thanks.


require “erb”

Create template.

template = %q{
From: James Edward G. II removed_email_address@domain.invalid
To: <%= to %>
Subject: Addressing Needs

<%= to[/\w+/] %>:

Just wanted to send a quick note assuring that your needs are being

I want you to know that my team will keep working on the issues,

<%# ignore numerous minor requests -- focus on priorities %>
% priorities.each do |priority|
  * <%= priority %>
% end

Thanks for your patience.

James Edward G. II

}.gsub(/^ /, ‘’)

message =, 0, “%<>”)

Set up template data.

to = “Community Spokesman <>”
priorities = [ “Run Ruby Q.”,
“Document Modules”,
“Answer Questions on Ruby T.” ]

Produce result.

email = message.result
puts email


On Feb 18, 2006, at 11:53 AM, Belorion wrote:

Any ideas what’s going on here?

Hmm, has ERB stopped defaulting to a top-level binding?

email = message.result

Change that to:

email = message.result(binding)

Can someone please patch the docs for me?

James Edward G. II