2008年5月6日 星期二

cgi

require 'cgi'

cgi's method name equals the tag it create
Hence, cgi.h1 create h1 tag

use + to combine the same level tag

ex:
cgi = CGI.new('html4')
cgi.out do
    cgi.html do
          cgi.head  do
                 "test head"
          end  +
          cgi.body do
                cgi.h1 {  "hello" } 
          end
    end
end

--->
<HTML><HEAD>test head </HEAD><BODY><H1>hello</H1></BODY></HTML>

cgi.params:
represent query string
ex:
http://localhost/cig-bin/test.cgi?name=peter&age=3
cgi.params =  { 'name'=>'peter',   'age'=>'3' }


沒有留言: