Creating HTML tags

J

John

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)
 
A

Ara.T.Howard

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'
===============================================================================
 

Ask a Question

Want to reply to this thread or ask your own question?

You'll need to choose a username for the site, which only take a couple of moments. After that, you can post your question and our members will help you out.

Ask a Question

Members online

Forum statistics

Threads
474,141
Messages
2,570,817
Members
47,361
Latest member
eitamoro

Latest Threads

Top