On Sat, Sep 10, 2005 at 11:12:21PM +0900, Gavin Kistner wrote:
> Proposed RCR:
> 
> Modify ERB so that calls to #puts, #print, and #p inside the template  
> append the resulting string onto the local ERB output variable,  
> instead of sending the output to $stdout. #warn would still send to  
> STDERR (for debug messages seen but kept out of the result string)  
> and $stdout#<< could also be used.

Why not just change $stdout, e.g.:

<%
require 'stringio'
$orig_stdout = $stdout
$stdout = StringIO.new(_erbout, 'a')
$stdout.sync = true
%>1
<% puts "2" %>3
<% $stdout = $orig_stdout %>

should print:

1
2
3

Then puts keeps the same behavior as it has now, and you get the result
you want using the existing behavior.

Paul