From: dblack@... Date: 2002-08-11T11:21:16+09:00 Subject: Re: extend Html4? Hi -- On Sun, 11 Aug 2002, Harry Ohlsen wrote: > > I'm not quite following. Do you mean this specifically in relation > > to the design of cgi.rb? > > Sorry, I should have been clearer. The original issue that was mentioned > (assuming I didn't come into the thread too late) was that if one does > something like: > > require 'cgi' > include CGI::Html3 > > this makes the module-level method available without specying the "namespace", > so that you can do things like: > > puts html { h1 { "Hello, world!" } } > > but that then the DOCTYPE specification doesn't end up in the output. > Instead, one sees something like > >

Hello, world!

> > I thought people were saying the reason for this was that the DOCTYPE stuff > only happens if one constructs a new CGI instance in the code. > > What I meant was that if the construction of that object has the side-effect > of setting up some infrastructure, then that infrastructure could, > potentially be set up as top-level code. That is what we were talking about, but it's all based on trying to do an end pass around the official API, so it's not something that I would really recommend being changed in cgi.rb :-) By the way, I did figure out why the DOCTYPE declaration doesn't appear: the factory-created #html method in a normal CGI object actually gets overridden by an "extend HtmlExtension". And, sure enough, if you do: require './cgi.rb' cgi = CGI.new("html4") include CGI::Html4, CGI::HtmlExtension puts html { } it does output the whole thing. But until we hear otherwise, I would assume this is all not guaranteed, as it's probing into the inner workings of the extension. (But quite interesting, isn't it? :-) David -- David Alan Black home: dblack@candle.superlink.net work: blackdav@shu.edu Web: http://pirate.shu.edu/~blackdav