On Sunday 11 December 2005 12:08, Wybo Dekker wrote:
> Why does this not work (bar->undefined) and what's a better way to
> do it?:
>
> require 'erb'
>
> FOO = 'Hello <%= bar %>'
> class Foo
>   def doit
>     bar = 'World!'
>     puts ERB.new(FOO).result

replace above line with:

      puts ERB.new(FOO).result(binding)

>   end
> end
>
> Foo.new.doit

Regards,
  Stefan