Newbie Q: Lowercase CGI output

I know this might be simple but I haven’t found a decent(simple Ruby
way) of doing this.

The CGI module outputs all the html tags in upper case. For my own
conceited reasons( and I heard this was the preferred method), I would
like the tags to be in lower case. The pretty method lines up
everything nicely but does nothing else. I have tried appending
.downcase to the string passed to pretty:

CGI.pretty (
cgi.html {
cgi.head {
cgi.title {“Input Page”}
} +
cgi.body {
cgi.h1 {“Main Page”} +
cgi.hr +
cgi.div {“Sven was here”}
}
}
).downcase

This works but it also kills any capitals in the text. Any suggestions?

Sven Schott

You will have to do downcase ala this (untested)… perhaps more downcasing
is necessary ?

require ‘cgi’
class CGI
module TagMaker
def nn_element_def(element)
<<-END.gsub(/element.downcase/n, element.downcase).gsub(/element.upcase/n, element.upcase)
“<element.downcase” + attributes.collect{|name, value|
next unless value
" " + CGI::escapeHTML(name.downcase) +
if true == value
“”
else
‘="’ + CGI::escapeHTML(value) + ‘"’
end
}.to_s + “>” +
if block_given?
yield.to_s
else
“”
end +
“</element.downcase>”
END
end
end # module TagMaker
end # class CGI

···

On Thu, 25 Mar 2004 13:00:05 +0900, Sven Schott wrote:

I know this might be simple but I haven’t found a decent(simple Ruby
way) of doing this.

The CGI module outputs all the html tags in upper case. For my own
conceited reasons( and I heard this was the preferred method), I would
like the tags to be in lower case. The pretty method lines up
everything nicely but does nothing else. I have tried appending
downcase to the string passed to pretty:


Simon Strandgaard

I know this might be simple but I haven’t found a decent(simple Ruby
way) of doing this.

The CGI module outputs all the html tags in upper case. For my own
conceited reasons( and I heard this was the preferred method), I would
like the tags to be in lower case.

yes, it is prefered. xhtml requires lower-case tags.

you should be able to simply set
cgi = CGI.new(“xhtml”).

my ruby here (1.6) did not have xhtml. if even cgi.rb in cvs does not have
xhtml1 this can be considered a bug, that needs fixing.

ruby is nice, so have fun.

~ibotty