CGI Lib

Hi all!

First of all thx to the makers of this wonderful language!

I going to use Ruby as a replacement to PHP and wonder, what
improvements to the CGI lib are already planned before I post my
suggestions :slight_smile:

btw, am I the only one who feels that this funny html support doesn’t
belongs to a cgi lib?!?

bye!
Dominik

btw, am I the only one who feels that this funny html support doesn’t
belongs to a cgi lib?!?

Just out of curiosity, what funny html support?
I haven’t played with Ruby/CGI much.

Daniel Carrera
Graduate Teaching Assistant. Math Dept.
University of Maryland. (301) 405-5137

dwerder@gmx.net (Dominik Werder) writes:

Hi all!

First of all thx to the makers of this wonderful language!

I going to use Ruby as a replacement to PHP and wonder, what
improvements to the CGI lib are already planned before I post my
suggestions :slight_smile:

btw, am I the only one who feels that this funny html support doesn’t
belongs to a cgi lib?!?

bye!
Dominik

I can’t speak specifically about ruby’s cgi lib because I haven’t used
it, but I can offer a strong recommendation for a ruby package called
“amrita” which you can find in RAA. More than any other server-side
markup-language generation tool that I’ve seen (whether in PHP, perl,
python, ruby, or whatever), amrita does an excellent job of separating
markup language and the program logic behind the generation thereof.
This is done through normal HTML or XML tag attributes, and without any
of the ugliness (IMHO) that results from embedding code inside of
special tags like “<? ?>”, “<% %>”, or whatever.

I consider amrita to be a huge improvement over the entire cgi paradigm,
let alone any implementation of a cgi lib, which is why I decided to
step in and answer your question in this thread.

¡¡¡

–
Lloyd Zusman
ljz@asfast.com

are you talking about the cgi.html { cgi.head { … } + cgi.body { … } }
stuff?

¡¡¡

On Wednesday 01 January 2003 04:10 pm, Daniel Carrera wrote:

btw, am I the only one who feels that this funny html support doesn’t
belongs to a cgi lib?!?

Just out of curiosity, what funny html support?
I haven’t played with Ruby/CGI much.

Daniel Carrera
Graduate Teaching Assistant. Math Dept.
University of Maryland. (301) 405-5137

I consider amrita to be a huge improvement over the entire cgi paradigm,
let alone any implementation of a cgi lib, which is why I decided to
step in and answer your question in this thread.

i’ll agree with two notes: the CGI lib is still needed for forms processing
(unless you do it all manually, yuk) whterh you use Amriata or eRuby or what
have you. Also the word is the Amrita is much slower. So if you app is
complex and speed an issue than eRuby seems to be the better solution. There
is hope that this will be corrected though, and then we can have the best of
both worlds!

there has been talk about work on the CGI lib before, i beleive. i don’t know
the status of the project, but there does seem like there is room for a
lighter-weight CGI lib. Perhps the “funny html support” should be sperated
into its own requirable module? that’s seems like a good start and would make
it a one liner fix to bring older packages up to date.

-transami

def xml(element, attributes = {})
content = block_given? ? yield : ‘’
content = content.join(‘’) if content.is_a?(Array)
tag = “<” + element + " "
attributes.each { |key, value| tag << "#{key}=‘#{value}’ " }
tag << “/” if content == ‘’
tag << “>”
tag << content << “</#{element}>” if content != ‘’
tag
end

what module?

¡¡¡

On Thu, 2 Jan 2003 08:24:24 +0900, Tom Sawyer transami@transami.net wrote:

Perhps the “funny html support” should be sperated
into its own requirable module?

are you talking about the cgi.html { cgi.head { … } + cgi.body { … } }
stuff?

btw, am I the only one who feels that this funny html support doesn’t
belongs to a cgi lib?!?
Just out of curiosity, what funny html support?
I haven’t played with Ruby/CGI much.

yes, I’m talking about these many nested code blocks…

Can anyone teach me the advantages of this kind of design?
And why does every html tag needs an own method?

thx!
Dominik

are you talking about the cgi.html { cgi.head { … } + cgi.body { …
} } stuff?

btw, am I the only one who feels that this funny html support
doesn’t belongs to a cgi lib?!?
Just out of curiosity, what funny html support?
I haven’t played with Ruby/CGI much.

yes, I’m talking about these many nested code blocks…

Can anyone teach me the advantages of this kind of design?
And why does every html tag needs an own method?

I found no real advantage, in fact, it is a real pain in the butt. Several
months back I posted some suggestions on http://rubycookbook.org on how to
use these (some) of these tags in a painless fashion, allowing embedded
code and such. Look it up there in the web section.

¡¡¡

On Sat, 4 Jan 2003 01:13:45 +0900 dwerder@gmx.net (Dominik Werder) wrote:

thx!
Dominik

–
“Daniel P. Zepeda” <daniel@z,e,p,e,d,a,-,z,o,n,e.net>
(Remove commas for address)

Hello,

$ cat test
require “cgi”
#cgi = CGI.new(“html3”) # ==> no error
cgi = CGI.new(“html4”)
cgi.out do
cgi.html do
cgi.body do
cgi.center do
cgi.p do
"text"
end
end
end
end
end
$ ruby test
test:7: undefined method `center’ for #CGI:0x402b8d64 (NoMethodError)

cgi.html{ # ==> parse error
cgi.br # ==>

cgi.br{} # ==>
# (BR element has no close tag)
cgi.h1 # ==>

# (H1 element can not omit close tag)
cgi.h1{} # ==>

¡¡¡

–
Wakou Aoyama wakou@ruby-lang.org

#cgi = CGI.new(“html3”) # ==> no error
cgi = CGI.new(“html4”)
test:7: undefined method `center’ for #CGI:0x402b8d64 (NoMethodError)

this error is raises because the html4 specs dont include the center tag anymore…

bye!
Dominik

this error is raises because the html4 specs dont include the center tag anymore…

Yes. It’s one of answer for question.

¡¡¡

On Sat, Jan 04, 2003 at 07:35:36PM +0900, Dominik Werder wrote:

Can anyone teach me the advantages of this kind of design?
And why does every html tag needs an own method?

–
Wakou Aoyama wakou@ruby-lang.org