From: dblack@... Date: 2002-08-11T09:16:01+09:00 Subject: Re: extend Html4? Hello -- On Sun, 11 Aug 2002, Philip Mak wrote: > Suppose I have this code: > > > $cgi = CGI.new('html4') > > puts $cgi.p{"Hello, "+$cgi.b{"world"}+"!"} >

Hello, world!

> > How can I become able to write it like this? > > > puts p{"Hello, "+b{"world"}+"!"} > > I want the "p", "b" etc. methods to be exported to my namespace. They > are defined inside Html4: > > class CGI > ... > module Html4 > ... > end > end > > I can't just type "extend Html4" because Html4 is defined inside the > CGI class. You can include the module, but keep reading below.... require 'cgi' include CGI::Html3 cgi = CGI.new("html3") puts html { h1 { "hi" } } For reasons I haven't fully looked into, this doesn't print the DOCTYPE declaration; it just prints:

hi

so it's probably treading where it shouldn't. But maybe it could point you in the right direction (if there is one :-) David -- David Alan Black home: dblack@candle.superlink.net work: blackdav@shu.edu Web: http://pirate.shu.edu/~blackdav