| |
In addition, CGI supports the following HTML output methods. Each
of these methods is named after the corresponding HTML feature (or
close to it). Those tags that require content (such as
blockquote) take an optional block; the block should return a
String that will be used as the content for the feature. These
methods may take arguments as indicated, or as a hash with the given
names as keys.
\
a(
url
)
a(
HREF
=> )
base(
url
)
base(
HREF
=> )
blockquote(
cite=""
) { aString }
blockquote(
CITE
=> ) { aString }
caption(
align=nil
) { aString }
caption(
ALIGN
=> ) { aString }
checkbox(
name=nil, value=nil, checked=nil
)
checkbox(
NAME, VALUE, CHECKED
=> )
checkbox_group(
name=nil, [
items
]+
)
checkbox_group( NAME, VALUES
=> )
Items may be individual String names, or any of:
an array of [ name, checked ],
an array of [ value, name ],
or an array of [ value, name, checked ].
The value for the hash key VALUES should be an array of these items.
file_field(
name="", size=20, maxlength=nil
)
file_field( NAME, SIZE, MAXLENGTH
=> )
form(
method="post", action=nil,
enctype="application/x-www-form-urlencoded" ) { aStr }
form( METHOD, ACTION, ENCTYPE
=> ) { aStr }
hidden(
name="", value=nil
)
hidden(
NAME, VALUE
=> )
html( ) { aString }
html(
PRETTY, DOCTYPE
=> ) { aString }
img_button(
src="", name=nil, alt=nil
)
img_button( SRC, NAME, ALT
=> )
img(
src="", alt="", width=nil, height=nil
)
img( SRC, ALT, WIDTH, HEIGHT
=> )
multipart_form(
action=nil, enctype="multipart/form-data" ) { aString }
multipart_form(
METHOD, ACTION, ENCTYPE
=> ) { aString }
password_field(
name="", value=nil, size=40,
maxlength=nil
)
password_field(
NAME, VALUE, SIZE, MAXLENGTH
=> )
popup_menu(
name="", items
)
popup_menu( NAME, SIZE, MULTIPLE, VALUES (array of items)
=> )
Items may be individual String names, or any of:
an array of [ name, selected ],
an array of [ value, name ],
or an array of [ value, name, selected ].
The value for the hash key VALUES should be an array of these items.
radio_button(
name="", value=nil, checked=nil
)
radio_button( NAME, VALUE, CHECKED
=> )
radio_group(
name="", items
)
radio_group(
NAME, VALUES
(array of items)
=> )
Items may be individual String names, or any of:
an array of [ name, selected ],
an array of [ value, name ],
or an array of [ value, name, selected ].
The value for the hash key VALUES should be an array of these items.
reset(
value=nil, name=nil
)
reset(
VALUE, NAME
=> )
scrolling_list(
alias for popup_menu )
scrolling_list( => )
submit(
value=nil, name=nil
)
submit(
VALUE, NAME
=> )
text_field(
name="", value=nil, size=40,
maxlength=nil
)
text_field(
NAME, VALUE, SIZE, MAXLENGTH => )
textarea(
name="", cols=70, rows=10 )
textarea( NAME, COLS, ROWS
=> )
\
In addition, all HTML tags are supported as methods, including
title, head, body, br, pre, and so on.
The block given to the method must return a String, which will be
used as the content for that tag type. Not all tags require content:
<P>, for example, does not.
The available tags vary according to the supported HTML level---Table
26.1 on page 503 lists the complete set. For these methods, you
can pass in a hash with attributes for the given tag. For instance, you
might pass in 'BORDER'=>'5' to the table method to set the
border width of the table.
|
|