From: Lyndon Samson Date: 2005-09-12T08:42:18+09:00 Subject: Re: RCR to modify #puts and #print inside ERB ------=_Part_7410_10252724.1126482136142 Content-Type: text/plain; charset=ISO-8859-1 Content-Transfer-Encoding: quoted-printable Content-Disposition: inline >=20 > One could capture the output by setting the default output to a > StringIO; this is similar to what I did in a previous solution. It is > rather easy to put together a simple, thread-safe version that does > this. Currently, the default is to capture the output as a string, but > a webserver-related use would probably just send the output directly > to the browser *as it is being output*, rather than building the > string and sending it all at once. >=20 > I don't see this as being about adding "magic" to the implementation. > If you are of the mindset that the template is concatting to a string, > the puts idea doesn't make sense; but if you see it as printing to an > output stream (with the whole _erbout thing just being an > implementation issue), then the lack of a working print/puts is what > doesn't make sense. >=20 >=20 Indeed, their are certain efficiencies not having to pre-generate all outpu= t=20 before transmission. Think file downloads, dynamic image generation etc. As a general tool, being able to reassign STDOUT/STDIN/STDERR to an IO woul= d=20 be very powerfull.=20 From my perspective, ERB's main usage is as a dynamic web page generator=20 means that its natural to think of all program output going 'to a web=20 browser' rather than to a console. ------=_Part_7410_10252724.1126482136142--