From: "Hal E. Fulton" Date: 2001-09-04T22:18:25+09:00 Subject: [ruby-talk:20861] Re: Minor cgi.rb question ----- Original Message ----- From: Niklas Frykholm To: ruby-talk ML Sent: Tuesday, September 04, 2001 3:39 AM Subject: [ruby-talk:20847] Re: Minor cgi.rb question > I agree that this is not very good... it is too easy to forget the '+'. > But outputting the data directly is not very good either... you may want > to postprocess the data or (for example) write it to a database. True. > Also, > I do not think that HTML generation really belongs in the CGI class. That's an interesting observation. I think I agree. Of course, they would frequently be used together. > But I do like the idea of using ruby blocks to indicate tag nesting. So do I. After I got used to it, I liked it very much. > > I think a nice design would be something like this: > > h = HTML.new('HTML3', [:lower_case, :pretty]) > h.html { > h.body { > h.h1('Larger header') > h.h2('Smaller header') > } > } > cgi.out(h.to_s) I like this. The "case" and "pretty" options are interesting. I assume that pretty means indentation and such? > The #body, #h1 and #h2 methods would append their data to the h object. > Do you agree or would you rather see something else? This seems good IMO. > Is HTML a good class > name or would HTMLGeneration be better? It is easy enough to code up once > the interface is decided. HTML is too general a name. HTMLGen or something is better. You might take a look at something I started once. It is in many ways crude and inelegant, and if I were going to finish it I would actually redesign it. See RHH (Ruby HTML Helper) on my (almost nonexistent) Ruby page at http://hypermetrics.com/ruby.html Cheers, Hal