From: James Edward Gray II Date: 2007-05-20T00:27:15+09:00 Subject: Re: PrettyPrint to a web page? On May 18, 2007, at 6:40 PM, Mario T. Lanza wrote: > This is gonna sound like a dumb question to you Ruby veterans, but: > How > do you dump pretty_print contents to a web page from within a Rails > app? > > I've tried this and a few other things from a view: > >

Session Info

> <% require 'pp' %> > <%= pp(session) %> Change that last line to: <%= PP.pp(session, String.new) %> pp() accepts a second argument to specify where to put the output. This just defaults to $> ($stdout). If we specify a String, the output is collected there instead: >> require "pp" => false >> Contact = Struct.new(:name, :city, :state, :email) => Contact >> james = Contact.new("James Edward Gray II", "Edmond", "Oklahoma", "james@grayproductions.net") => # >> pp_james = String.new => "" >> PP.pp(james, pp_james) => "#\n" >> puts pp_james # => nil James Edward Gray II