From: Ross Bamford Date: 2006-01-05T20:58:01+09:00 Subject: Re: Redirecting CGI#out to a string On Thu, 05 Jan 2006 11:05:01 -0000, wrote: > I'd prefer to generate my html using the CGI class, but webrick needs a > string to be returned and CGI#out writes to standard output. > I've not used CGI much myself, but a quick experiment yielded this: require 'cgi' cgi = CGI.new('html4') html = cgi.html do cgi.body do cgi.pre do "Don't use 'out'" end end end # Now you can do what you want with it, for example: puts CGI.pretty(html.gsub(/<([^!][^>]*)>/) { "<#{$1.downcase}>" }) Outputs:
	      Don't use 'out'
	    
I don't know if it's the best tool for your task, but anyway I hope that helps... -- Ross Bamford - rosco@roscopeco.remove.co.uk