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]