James Edward Gray II wrote:
> On Oct 27, 2004, at 5:45 PM, Bill Atkins wrote:
> 
>> So, is the conclusion that puts's and print's in ERB source will go to
>> STDOUT?  Is there a way to have their output added to the ERB result?
>> This seems like an important behavior to support.
> 
> 
> Concat to eoutvar?  Use <%= ... %> liberally?
> 
> James Edward Gray II
> 
> 
> 

I noticed this other other day while doing some testing as well, and I 
was quite suprised that all the documentation seemed to indicate the 
opposite of what it does.  It at least directly conflict with the 
documentation in The Ruby Way, pickaxe II seems to escape by not using 
any examples with puts or print inside erb.

I'm not quite sure how to go about doing this, but for the scope of erb 
perhaps it would work better if Kernel.puts and Kernel.print were 
aliased to _erbout.concat (with the appropriate line ending behavior). 
Thus if you want debug info prepending from STDOUT you can explicitly 
call STDOUT.puts or STDOUT.print but otherwise I believe it should go in 
the right order.  That or perhaps mess around with making _erbout a 
StringIO object instead of a string and directly aliasing to puts and 
print on it.

On a side note the commandline options to erb have a few issues.  First 
it says:
  -d               set $DBEUG to true

and also the -n modifier which is supposed to add line numbers only adds 
them if the source code output is set.  IMHO, it should either add line 
numbers in both cases, or always assume -x was set.

Anyone happen to know the difference between ERB.new("text").run and 
ERB.new("text").result ?

Also, this has always bothered me, what is the difference between eruby 
and erb?  Just one is a compiled C extension or is there any other reason?

Charles Comstock