cgi font not working (ruby 1.8)

T

tigre

Hi all, i'm relative new to ruby. I've been using CGI class to make a simple
script, but what i found when using cgi.font the next error:

/pass.cgi:28: undefined method `font' for #<CGI:0x40308180> (NoMethodError)

Isn't font implemented?

Thx.
 
M

Mark Hubbart

Hi all, i'm relative new to ruby. I've been using CGI class to make a
simple
script, but what i found when using cgi.font the next error:

./pass.cgi:28: undefined method `font' for #<CGI:0x40308180>
(NoMethodError)

Isn't font implemented?

If you want to use the font tag, you must use html3, not html4; W3C
either deprecated or removed it in the html4 spec.

irb(main):040:0> c=CGI.new('html4')
[...]
irb(main):041:0> c.font{"test"}
NoMethodError: undefined method `font' for #<CGI:0x59978c>
from (irb):41

irb(main):042:0> c=CGI.new('html3')
[...]
irb(main):043:0> c.font{"test"}
=> "<FONT>test</FONT>"

But it would be a better choice to use styles, since the font tag is
considered somewhat of a no-no these days. You might want to try this
instead:

irb(main):044:0> c=CGI.new('html4')
[...]
irb(main):045:0> c.span('style'=>"font-family:Garamond,Georgia,'Times
New Roman',serif"){"text goes here"}
=> "<SPAN style=\"font-family:Garamond,Georgia,'Times New
Roman',serif\">text goes here</SPAN>"


cheers,
--Mark
 

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

No members online now.

Forum statistics

Threads
474,145
Messages
2,570,824
Members
47,370
Latest member
desertedtyro29

Latest Threads

Top