Ruby 1.9.2 リファレンスマニュアル > ライブラリ一覧 > cgiライブラリ > CGI::HtmlExtensionモジュール

module CGI::HtmlExtension

クラスの継承リスト: CGI::HtmlExtension

Abstract

インスタンスメソッド

a(href = "")
例:
a("url")
  # = a({ "HREF" => "url" })
base(href = "")
例:
base("url")
  # = base({ "HREF" => "url" })
blockquote(cite = nil)
例:
blockquote("url"){ "string" }
  # = blockquote({ "CITE" => "url" }){ "string" }
caption(align = nil)
例:
caption("align"){ "string" }
  # = caption({ "ALIGN" => "align" }){ "string" }
checkbox(name = "", value = nil, checked = nil)
例:
checkbox("name")
  # = checkbox({ "NAME" => "name" })

checkbox("name", "value")
  # = checkbox({ "NAME" => "name", "VALUE" => "value" })

checkbox("name", "value", true)
  # = checkbox({ "NAME" => "name", "VALUE" => "value", "CHECKED" => true })
checkbox_group(name = "", *values)
例:
checkbox_group("name", "foo", "bar", "baz")
  # <INPUT TYPE="checkbox" NAME="name" VALUE="foo">foo
  # <INPUT TYPE="checkbox" NAME="name" VALUE="bar">bar
  # <INPUT TYPE="checkbox" NAME="name" VALUE="baz">baz

checkbox_group("name", ["foo"], ["bar", true], "baz")
  # <INPUT TYPE="checkbox" NAME="name" VALUE="foo">foo
  # <INPUT TYPE="checkbox" SELECTED NAME="name" VALUE="bar">bar
  # <INPUT TYPE="checkbox" NAME="name" VALUE="baz">baz

checkbox_group("name", ["1", "Foo"], ["2", "Bar", true], "Baz")
  # <INPUT TYPE="checkbox" NAME="name" VALUE="1">Foo
  # <INPUT TYPE="checkbox" SELECTED NAME="name" VALUE="2">Bar
  # <INPUT TYPE="checkbox" NAME="name" VALUE="Baz">Baz

checkbox_group({ "NAME" => "name",
                 "VALUES" => ["foo", "bar", "baz"] })

checkbox_group({ "NAME" => "name",
                 "VALUES" => [["foo"], ["bar", true], "baz"] })

checkbox_group({ "NAME" => "name",
                 "VALUES" => [["1", "Foo"], ["2", "Bar", true], "Baz"] })
file_field(name = "", size = 20, maxlength = nil)
例:
file_field("name")
  # <INPUT TYPE="file" NAME="name" SIZE="20">

file_field("name", 40)
  # <INPUT TYPE="file" NAME="name" SIZE="40">

file_field("name", 40, 100)
  # <INPUT TYPE="file" NAME="name" SIZE="40" MAXLENGTH="100">

file_field({ "NAME" => "name", "SIZE" => 40 })
  # <INPUT TYPE="file" NAME="name" SIZE="40">
form(method = "post", action = nil, enctype = "application/x-www-form-urlencoded")
例:
form{ "string" }
  # <FORM METHOD="post" ENCTYPE="application/x-www-form-urlencoded">string</FORM>

form("get"){ "string" }
  # <FORM METHOD="get" ENCTYPE="application/x-www-form-urlencoded">string</FORM>

form("get", "url"){ "string" }
  # <FORM METHOD="get" ACTION="url" ENCTYPE="application/x-www-form-urlencoded">string</FORM>

form({"METHOD" => "post", ENCTYPE => "enctype"}){ "string" }
  # <FORM METHOD="post" ENCTYPE="enctype">string</FORM>
hidden(name = "", value = nil)
例:
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="name" VALUE="value" ID="foo">
html(attributes = {})
例:

html{ "string" }
  # <!DOCTYPE HTML PUBLIC "-//W3C//DTD HTML 3.2 Final//EN"><HTML>string</HTML>

html({ "LANG" => "ja" }){ "string" }
  # <!DOCTYPE HTML PUBLIC "-//W3C//DTD HTML 3.2 Final//EN"><HTML LANG="ja">string</HTML>

html({ "DOCTYPE" => false }){ "string" }
  # <HTML>string</HTML>

html({ "DOCTYPE" => '<!DOCTYPE HTML PUBLIC "-//IETF//DTD HTML//EN">' }){ "string" }
  # <!DOCTYPE HTML PUBLIC "-//IETF//DTD HTML//EN"><HTML>string</HTML>

html({ "PRETTY" => "  " }){ "<BODY></BODY>" }
  # <!DOCTYPE HTML PUBLIC "-//W3C//DTD HTML 3.2 Final//EN">
  # <HTML>
  #   <BODY>
  #   </BODY>
  # </HTML>

html({ "PRETTY" => "\t" }){ "<BODY></BODY>" }
  # <!DOCTYPE HTML PUBLIC "-//W3C//DTD HTML 3.2 Final//EN">
  # <HTML>
  #         <BODY>
  #         </BODY>
  # </HTML>

html("PRETTY"){ "<BODY></BODY>" }
  # = html({ "PRETTY" => "  " }){ "<BODY></BODY>" }

html(if $VERBOSE then "PRETTY" end){ "HTML string" }
image_button(src = "", name = nil, alt = nil)
例:
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" => "url", "ALT" => "string" })
  # <INPUT TYPE="image" SRC="url" ALT="string">
img(src = "", alt = "", width = nil, height = nil)
例:
img("src", "alt", 100, 50)
  # <IMG SRC="src" ALT="alt" WIDTH="100" HEIGHT="50">

img({ "SRC" => "src", "ALT" => "alt", "WIDTH" => 100, "HEIGHT" => 50 })
  # <IMG SRC="src" ALT="alt" WIDTH="100" HEIGHT="50">
multipart_form(action = nil, enctype = "multipart/form-data")
例:
multipart_form{ "string" }
  # <FORM METHOD="post" ENCTYPE="multipart/form-data">string</FORM>

multipart_form("url"){ "string" }
  # <FORM METHOD="post" ACTION="url" ENCTYPE="multipart/form-data">string</FORM>
password_field(name = "", value = nil, size = 40, maxlength = nil)
例:
password_field("name")
  # <INPUT TYPE="password" NAME="name" SIZE="40">

password_field("name", "value")
  # <INPUT TYPE="password" NAME="name" VALUE="value" SIZE="40">

password_field("password", "value", 80, 200)
  # <INPUT TYPE="password" NAME="name" VALUE="value" SIZE="80" MAXLENGTH="200">

password_field({ "NAME" => "name", "VALUE" => "value" })
  # <INPUT TYPE="password" NAME="name" VALUE="value">
popup_menu(name = "", *values)
例:
popup_menu("name", "foo", "bar", "baz")
  # <SELECT NAME="name">
  #   <OPTION VALUE="foo">foo</OPTION>
  #   <OPTION VALUE="bar">bar</OPTION>
  #   <OPTION VALUE="baz">baz</OPTION>
  # </SELECT>

popup_menu("name", ["foo"], ["bar", true], "baz")
  # <SELECT NAME="name">
  #   <OPTION VALUE="foo">foo</OPTION>
  #   <OPTION VALUE="bar" SELECTED>bar</OPTION>
  #   <OPTION VALUE="baz">baz</OPTION>
  # </SELECT>

popup_menu("name", ["1", "Foo"], ["2", "Bar", true], "Baz")
  # <SELECT NAME="name">
  #   <OPTION VALUE="1">Foo</OPTION>
  #   <OPTION SELECTED VALUE="2">Bar</OPTION>
  #   <OPTION VALUE="Baz">Baz</OPTION>
  # </SELECT>

popup_menu({"NAME" => "name", "SIZE" => 2, "MULTIPLE" => true,
            "VALUES" => [["1", "Foo"], ["2", "Bar", true], "Baz"] })
  # <SELECT NAME="name" MULTIPLE SIZE="2">
  #   <OPTION VALUE="1">Foo</OPTION>
  #   <OPTION SELECTED VALUE="2">Bar</OPTION>
  #   <OPTION VALUE="Baz">Baz</OPTION>
  # </SELECT>
radio_button(name = "", value = nil, checked = nil)
例:
radio_button("name", "value")
  # <INPUT TYPE="radio" NAME="name" VALUE="value">

radio_button("name", "value", true)
  # <INPUT TYPE="radio" NAME="name" VALUE="value" CHECKED>

radio_button({ "NAME" => "name", "VALUE" => "value", "ID" => "foo" })
  # <INPUT TYPE="radio" NAME="name" VALUE="value" ID="foo">
radio_group(name = "", *values)
例:
radio_group("name", "foo", "bar", "baz")
  # <INPUT TYPE="radio" NAME="name" VALUE="foo">foo
  # <INPUT TYPE="radio" NAME="name" VALUE="bar">bar
  # <INPUT TYPE="radio" NAME="name" VALUE="baz">baz

radio_group("name", ["foo&quot;], ["bar", true], "baz")
  # <INPUT TYPE="radio" NAME="name" VALUE="foo">foo
  # <INPUT TYPE=&quot;radio" CHECKED NAME="name" VALUE="bar">bar
  # <INPUT TYPE="radio" NAME="name" VALUE="baz">baz

radio_group("name", ["1", "Foo"], ["2", "Bar", true], "Baz")
  # <INPUT TYPE="radio" NAME="name" VALUE="1">Foo
  # <INPUT TYPE="radio" CHECKED NAME="name" VALUE="2">Bar
  # <INPUT TYPE="radio" NAME="name" VALUE="Baz">Baz

radio_group({ "NAME" => "name",
              "VALUES" => ["foo", "bar", "baz"] })

radio_group({ "NAME" => "name",
              "VALUES" => [["foo"], ["bar", true], "baz"] })

radio_group({ "NAME" => "name",
              "VALUES" => [["1", "Foo"], ["2", "Bar", true], "Baz"] })
reset(value = nil, name = nil)
例:
reset
  # <INPUT TYPE="reset">

reset("reset")
  # <INPUT TYPE="reset" VALUE="reset">

reset({ "VALUE" => "reset", "ID" => "foo" })
  # <INPUT TYPE="reset" VALUE="reset" ID="foo">
scrolling_list(name = "", *values)
例:

scrolling_list({"NAME" => "name", "SIZE" => 2, "MULTIPLE" => true,
                "VALUES" => [["1", "Foo"], ["2", "Bar", true], "Baz"] })
  # <SELECT NAME="name" MULTIPLE SIZE="2">
  #   <OPTION VALUE="1">Foo</OPTION>
  #   <OPTION SELECTED VALUE="2">Bar</OPTION>
  #   <OPTION VALUE="Baz">Baz</OPTION>
  # </SELECT>
submit(value = nil, name = nil)
例:
submit
  # <INPUT TYPE="submit">

submit("ok")
  # <INPUT TYPE="submit" VALUE="ok">

submit("ok", "button1")
  # <INPUT TYPE="submit" VALUE="ok" NAME="button1">

submit({ "VALUE" => "ok", "NAME" => "button1", "ID" => "foo" })
  # <INPUT TYPE="submit" VALUE="ok" NAME="button1" ID="foo">
text_field(name = "", value = nil, size = 40, maxlength = nil)
例:
text_field("name")
  # <INPUT TYPE="text" NAME="name" SIZE="40">

text_field("name", "value")
  # <INPUT TYPE="text" NAME="name" VALUE="value" SIZE="40">

text_field("name", "value", 80)
  # <INPUT TYPE="text" NAME="name" VALUE="value" SIZE="80">

text_field("name", "value", 80, 200)
  # <INPUT TYPE="text" NAME="name" VALUE="value" SIZE="80" MAXLENGTH="200">

text_field({ "NAME" => "name", "VALUE" => "value" })
  # <INPUT TYPE="text" NAME="name" VALUE="value">
textarea(name = "", cols = 70, rows = 10)
例:
textarea("name")
  # = textarea({ "NAME" => "name", "COLS" => 70, "ROWS" => 10 })

textarea("name", 40, 5)
  # = textarea({ "NAME" => "name", "COLS" => 40, "ROWS" => 5 })

Methods

Classes