From: Chris Eskow Date: 2006-08-08T12:37:17+09:00 Subject: Re: Extracting instance variables from a block? Wait! I got it! Instead of keeping an object to store the binding in, I can store the Proc object's binding itself: class Web def initialize @pages = {} @binding = nil end def page(regexp, &action) @pages[/^#{regexp}$/] = action end def render(template) print CGI.new.header('text/html') ERB.new(File.read(template)).run(@binding) end def run for regexp, action in @pages if ENV['REQUEST_URI'] =~ regexp @binding = action.binding action[*$~.to_a[1..-1]] return end end end end As you can see, once I found the matching page, I store its action's binding (by calling Proc#binding) into an instance variable (@binding), right before I actually call the action. Then, when running the ERB template, I use @binding for template's binding. Thanks for your help, anyway! Chris -- Posted via http://www.ruby-forum.com/.