checkbox

checkbox(name = "", value = nil, checked = nil) Instance Public methods Generate a Checkbox Input element as a string. The attributes of the element can be specified as three arguments, name, value, and checked. checked is a boolean value; if true, the CHECKED attribute will be included in the element. Alternatively, the attributes can be specified as a hash. checkbox("name") # = checkbox("NAME" => "name") checkbox("name", "value") # = checkbox("NAME" => "name", "VALUE"

checkbox_group

checkbox_group(name = "", *values) Instance Public methods Generate a sequence of checkbox elements, as a String. The checkboxes will all have the same name attribute. Each checkbox is followed by a label. There will be one checkbox for each value. Each value can be specified as a String, which will be used both as the value of the VALUE attribute and as the label for that checkbox. A single-element array has the same effect. Each value can also be specified as a three-element arr

file_field

file_field(name = "", size = 20, maxlength = nil) Instance Public methods Generate an File Upload Input element as a string. The attributes of the element can be specified as three arguments, name, size, and maxlength. maxlength is the maximum length of the file's name, not of the file's contents. Alternatively, the attributes can be specified as a hash. See multipart_form() for forms that include file uploads. file_field("name") # <INPUT TYPE="file" NAME="name" SIZE="20">

form

form(method = "post", action = script_name, enctype = "application/x-www-form-urlencoded") Instance Public methods Generate a Form element as a string. method should be either âgetâ or âpostâ, and defaults to the latter. action defaults to the current CGI script name. enctype defaults to âapplication/x-www-form-urlencodedâ. Alternatively, the attributes can be specified as a hash. See also multipart_form() for forms that include file uploads. form{ "string" } # <FORM METHOD="

hidden

hidden(name = "", value = nil) Instance Public methods Generate a Hidden Input element as a string. The attributes of the element can be specified as two arguments, name and value. Alternatively, the attributes can be specified as a hash. hidden("name") # <INPUT TYPE="hidden" NAME="name"> hidden("name", "value") # <INPUT TYPE="hidden" NAME="name" VALUE="value"> hidden("NAME" => "name", "VALUE" => "reset", "ID" => "foo") # <INPUT TYPE="hidden" NAME="n

html

html(attributes = {}) Instance Public methods Generate a top-level HTML element as a string. The attributes of the element are specified as a hash. The pseudo-attribute âPRETTYâ can be used to specify that the generated HTML string should be indented. âPRETTYâ can also be specified as a string as the sole argument to this method. The pseudo-attribute âDOCTYPEâ, if given, is used as the leading DOCTYPE SGML tag; it should include the entire text of this tag, including angle brack

image_button

image_button(src = "", name = nil, alt = nil) Instance Public methods Generate an Image Button Input element as a string. src is the URL of the image to use for the button. name is the input name. alt is the alternative text for the image. Alternatively, the attributes can be specified as a hash. image_button("url") # <INPUT TYPE="image" SRC="url"> image_button("url", "name", "string") # <INPUT TYPE="image" SRC="url" NAME="name" ALT="string"> image_button("SRC"

img

img(src = "", alt = "", width = nil, height = nil) Instance Public methods Generate an Image element as a string. src is the URL of the image. alt is the alternative text for the image. width is the width of the image, and height is its height. Alternatively, the attributes can be specified as a hash. img("src", "alt", 100, 50) # <IMG SRC="src" ALT="alt" WIDTH="100" HEIGHT="50"> img("SRC" => "src", "ALT" => "alt", "WIDTH" => 100, "HEIGHT" => 50) # <IMG S

multipart_form

multipart_form(action = nil, enctype = "multipart/form-data") Instance Public methods Generate a Form element with multipart encoding as a String. Multipart encoding is used for forms that include file uploads. action is the action to perform. enctype is the encoding type, which defaults to âmultipart/form-dataâ. Alternatively, the attributes can be specified as a hash. multipart_form{ "string" } # <FORM METHOD="post" ENCTYPE="multipart/form-data">string</FORM> mult

password_field

password_field(name = "", value = nil, size = 40, maxlength = nil) Instance Public methods Generate a Password Input element as a string. name is the name of the input field. value is its default value. size is the size of the input field display. maxlength is the maximum length of the inputted password. Alternatively, attributes can be specified as a hash. password_field("name") # <INPUT TYPE="password" NAME="name" SIZE="40"> password_field("name", "value") # <INP