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.

Why?hun…

Thanks

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

ri says:

require ‘erb’

   x = 42
   template = ERB.new <<-EOF
     The value of x is: <%= x %>
   EOF
   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]
http://lists.rubyonrails.org/mailman/listinfo/rails


Kent

http://www.datanoise.com

Just use terminal I guess.

$ ri ERB

This forum is not affiliated to the Ruby language, Ruby on Rails framework, nor any Ruby applications discussed here.

| Privacy Policy | Terms of Service | Remote Ruby Jobs