Date: 12 Dec 2003 09:16:31 -0800
From: John <
[email protected]>
Newsgroups: comp.lang.ruby
Subject: Creating HTML tags
I would like to be able to use the HTML generation methods from the
cgi library without instantiating a new CGI. Can I do this?
I've tried saying include CGI::HtmlExtension
require 'cgi'
class Thing
include CGI::HtmlExtension
def initialize
puts blockquote() {"hello"}
end
end
but I get cgi.rb:1382:in `blockquote': super: no superclass method
`blockquote' (NoMethodError)
~/eg/ruby > cat cgiext.rb
require 'cgi'
class Thing
def initialize type = 'html3'
case type
when "html3"
extend CGI::Html3
element_init()
extend CGI::HtmlExtension
when "html4"
extend CGI::Html4
element_init()
extend CGI::HtmlExtension
when "html4Tr"
extend CGI::Html4Tr
element_init()
extend CGI::HtmlExtension
when "html4Fr"
extend CGI::Html4Tr
element_init()
extend CGI::Html4Fr
element_init()
extend CGI::HtmlExtension
else
raise ArgumentError, type.to_s
end
puts blockquote() {"hello"}
end
end
Thing.new
~/eg/ruby > ruby cgiext.rb
<BLOCKQUOTE>hello</BLOCKQUOTE>
-a
--
ATTN: please update your address books with address below!
===============================================================================
| EMAIL :: Ara [dot] T [dot] Howard [at] noaa [dot] gov
| PHONE :: 303.497.6469
| ADDRESS :: E/GC2 325 Broadway, Boulder, CO 80305-3328
| STP ::
http://www.ngdc.noaa.gov/stp/
| NGDC ::
http://www.ngdc.noaa.gov/
| NESDIS ::
http://www.nesdis.noaa.gov/
| NOAA ::
http://www.noaa.gov/
| US DOC ::
http://www.commerce.gov/
|
| The difference between art and science is that science is what we
| understand well enough to explain to a computer.
| Art is everything else.
| -- Donald Knuth, "Discover"
|
| /bin/sh -c 'for l in ruby perl;do $l -e "print \"\x3a\x2d\x29\x0a\"";done'
===============================================================================