Generating HTML : HTML « CGI « Ruby






Generating HTML


require 'cgi' 
cgi = CGI.new("html3") # add HTML generation methods 
cgi.out { 
    cgi.html { 
        cgi.head { "\n"+cgi.title{"This Is a Test"} } + 
        cgi.body { "\n"+ 
            cgi.form {"\n"+ 
                cgi.hr + 
                cgi.h1 { "A Form: " } + "\n"+ 
                cgi.textarea("get_text") +"\n"+ 
                cgi.br + 
                cgi.submit 
            } 
        } 
    } 
} 

 








Related examples in the same category

1.CGI.escape and CGI.unescape.
2.CGI.escapeHTML
3.CGI.escapeElement
4.CGI.unescapeHTML
5.Output a string to web
6.CGI for creating a web page
7.nested cgi.tag to create HTML document
8.Create a hash of HTTP response headers