Niklas Frykholm wrote:
> [Hal E. Fulton]
> > Suppose I want to follow an H1
> > header with an H2 header. Fine...
> > 
> > cgi.out do
> >   cgi.html do
> >     cgi.body do
> >       cgi.h1 { "Larger header" } +
> >       cgi.h2 { "Smaller header" }
> >     end
> >   end
> > end
> ...
> > Couldn't it have been written in such 
> > a way that output would have been
> > done as we went along, or at least
> > collected as we went along? 
> 
> 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. Also,
> I do not think that HTML generation really belongs in the CGI class.
> But I do like the idea of using ruby blocks to indicate tag nesting.
> 
> 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)

 	h = HTML.new('HTML3', [:lower_case, :pretty])
 	h.html {
 		body {
 			h1('Larger header')
 			h2('Smaller header')
 		}
 	}

This would be possible, too. Inner blocks are just evaluated with instance_eval inside
the HTML class, whidh provides the methods body, h1, h2 etc..


Regards,

  Michael



-- 
Michael Neumann
merlin.zwo InfoDesign GmbH
http://www.merlin-zwo.de