From: "David A. Black" Date: 2005-01-13T01:12:55+09:00 Subject: Re: Webrick, erb, and .rhtml Hi -- On Thu, 13 Jan 2005, Belorion wrote: > Serving up html works fine. However, serving up .rhtml does not work. > If I visit my test.rhtml, whose contents are: > > > testing, 1234 > <% > 10.times{ |i| puts i } > %> > > > All I get as output on my browser is "testing, 1234", whose source looks like > > testing, 1234 > > > At the command prompt, if I ruby "erb test.rhtml" I get: > > 0 > 1 > 2 > 3 > 4 > 5 > 6 > 7 > 8 > 9 > > > > > testing, 1234 > > > > > > Which is obviously incorrect. What am I doing wrong here? I am using > ruby 1.8.2 (2004-07-29), and erb 2.0.4. You need <%= %> rather than <% %>. But keep in mind that what erb will show you is the result of evaluating the expression. The result of evaluating 10.times {...} is 10 -- and the result of evaluating puts is nil. So if you want to display all the numbers, you'd want something like: <%= (1..10).to_a.join(", ") %> David -- David A. Black dblack@wobblini.net