From: eduard Date: 2006-01-20T02:10:27+09:00 Subject: Re: output buffering ------=_Part_837_9840112.1137690613804 Content-Type: text/plain; charset=ISO-8859-1 Content-Transfer-Encoding: quoted-printable Content-Disposition: inline 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 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 =3D StringIO.new() > > # redirect STDOUT > $stdout =3D tmp_out > > puts "this and that" # would normally go to STDOUT > > # restore default stdout > $stdout =3D 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 > > ------=_Part_837_9840112.1137690613804--