About ERB sample

Hi list:

I run the ri’s ERB doc 1st sample

  1. require ‘erb’

  2. x = 42

  3. template = ERB.new <<-EOF

  4. The value of x is:

  5. EOF

  6. puts template.result(binding)

the doc say it will print

“The value of x is: 42”

but my irb print “nil” and there is a

“=> #<ERB:0x2970b24 @src=”_erbout = ‘’; _erbout.concat " The value
of x
is: \n"\n_erbout", @filename=nil, @safe_level=nil>"

at the end of 5th line.



Thanks. It¡¯s work well now:)
I use the RDT’s ri view to lookup api, there’s any other way to look api
will not loose information?

ri says:

require ‘erb’

   x = 42
   template = ERB.new <<-EOF
     The value of x is: <%= x %>
   puts template.result(binding)

My wild guess would be that you are using html output of ri command
which doesn’t correctly escape <,> characters.

On 7/25/06, Harry H. [email protected] wrote:

  1. template = ERB.new <<-EOF

Rails mailing list
[email protected]


Just use terminal I guess.

$ ri ERB