eduard
1/19/2006 5:10:00 PM
Mark,
I am having a similar problem. Have you ever figured out how to do
ob_start() in Ruby?
thanks,
eduard
On 1/2/06, Alex Fenton <alex@deleteme.pressure.to> wrote:
>
> hi
>
> mark wrote:
> > Is there any way to do php-style output buffering with ruby or rails?
> > as in:
> > ob_start()
>
> In ruby, generally, you'd achieve the same thing by redirecting $stdout.
> Something like:
>
> require 'stringio'
> tmp_out = StringIO.new()
>
> # redirect STDOUT
> $stdout = tmp_out
>
> puts "this and that" # would normally go to STDOUT
>
> # restore default stdout
> $stdout = STDOUT
>
> tmp_out.rewind()
> puts tmp_out.read() # print out what was sent to STDOUT
>
> I don't know whether Ruby on Rails has any special facility for
> temporarily
> redirecting output of literal HTML snippets within a mixed Ruby-HTML
> template (as the PHP function does, iirc). The rails mailing list should be
> able to help you with that one.
>
> cheers
> alex
>
>