From: Gavin Kistner Date: 2004-10-27T11:32:58+09:00 Subject: Re: Learning erb On Oct 26, 2004, at 6:21 PM, James Edward Gray II wrote: > "Insert the given Ruby code at this point in the generated program. > If it outputs anything, include the output in the result." > > It's the last line that's confusing me. If I feed erb: [...] > % a = 99 > <%= a %> bottles of beer... > 99 bottles of beer... > > % a = 99 > <% a %> bottles of beer... > bottles of beer... > > % a = 99 > <% print a %> bottles of beer... > 99 bottles of beer... [...] > So, what the heck does "If it outputs anything, include the output in > the result." really mean? I'm confused. I'm not sure what your question is. Perhaps this final test will make the end result (if not the magic mechanism) clear: a = 99 b = 12 puts ERB.new( "<%= print a; b %> bottles of beer" ).result( binding ) #=> 9912 bottles of beer puts ERB.new( "<%= puts a; b %> bottles of beer" ).result( binding ) #=> 99 #=> 12 bottles of beer a) Without the =, run the ruby code. Any strings output by print, puts, etc. replace the block. b) With the =, as above, except that the return value of the block should have .to_s called on it and appended to any output. Thanks for doing the work to document this, James!