要約
HTML の要素を生成するメソッドの実装を提供するモジュールです。
CGI::Html3・CGI::Html4・CGI::Html4Tr・CGI::Html4Fr・CGI::Html5 の各モジュールが include し、要素名と同名のメソッド(html・p・br など)の実体として利用しています。通常はこのモジュールのメソッドを直接呼び出す必要はありません。
目次
インスタンスメソッド
nOE_element(element, attributes = {}) -> StringRuby 2.1.0 から Ruby 4.0 で削除[permalink][rdoc][edit]-
空要素(終了タグを持たない要素)の開始タグを生成して返します。
- [PARAM]
element: - 要素名を指定します。タグ名は大文字に変換されます。
- [PARAM]
attributes: -
属性名をキー・属性値を値とする Hash を指定します。値が
trueの属性は属性名だけを出力し、値が偽の属性は出力しません。属性名の文字列を指定すると、その属性名だけを出力します。
require "cgi" cgi = CGI.new("html4") p cgi.nOE_element("input", "type" => "checkbox", "checked" => true) # => "<INPUT type=\"checkbox\" checked>" p cgi.nOE_element("br") # => "<BR>" - [PARAM]
nn_element_def(attributes = {}) -> StringRuby 4.0 で削除[permalink][rdoc][edit]nn_element_def(attributes = {}) { ... } -> StringnOE_element_def(attributes = {}) -> StringnO_element_def(attributes = {}) -> StringnO_element_def(attributes = {}) { ... } -> String-
要素名と同名のメソッド(
html・br・pなど)の実体です。呼び出されたメソッド名を要素名として、それぞれ CGI::TagMaker#nn_element・CGI::TagMaker#nOE_element・CGI::TagMaker#nO_element を呼び出します。- [PARAM]
attributes: - 属性名をキー・属性値を値とする Hash または属性名の文字列を指定します。
- [PARAM]
nO_element(element, attributes = {}) -> StringRuby 2.1.0 から Ruby 4.0 で削除[permalink][rdoc][edit]nO_element(element, attributes = {}) { ... } -> String-
終了タグを省略できる要素を生成して返します。
- [PARAM]
element: - 要素名を指定します。タグ名は大文字に変換されます。
- [PARAM]
attributes: -
属性名をキー・属性値を値とする Hash を指定します。値が
trueの属性は属性名だけを出力し、値が偽の属性は出力しません。属性名の文字列を指定すると、その属性名だけを出力します。 - [RETURN]
- ブロックを与えた場合はその返り値を内容として開始タグと終了タグで囲んだ文字列を、与えなかった場合は開始タグだけの文字列を返します。
require "cgi" cgi = CGI.new("html4") p cgi.nO_element("p") { "text" } # => "<P>text</P>" p cgi.nO_element("p") # => "<P>" - [PARAM]
nn_element(element, attributes = {}) -> StringRuby 2.1.0 から Ruby 4.0 で削除[permalink][rdoc][edit]nn_element(element, attributes = {}) { ... } -> String-
開始タグと終了タグの両方が必要な要素を生成して返します。
- [PARAM]
element: - 要素名を指定します。タグ名は大文字に変換されます。
- [PARAM]
attributes: -
属性名をキー・属性値を値とする Hash を指定します。値が
trueの属性は属性名だけを出力し、値が偽の属性は出力しません。属性名の文字列を指定すると、その属性名だけを出力します。 - [RETURN]
- ブロックを与えた場合はその返り値を内容として開始タグと終了タグで囲んだ文字列を、与えなかった場合は開始タグと終了タグだけの文字列を返します。
require "cgi" cgi = CGI.new("html4") p cgi.nn_element("div", "class" => "note") { "text" } # => "<DIV class=\"note\">text</DIV>" p cgi.nn_element("div") # => "<DIV></DIV>" - [PARAM]