module CGI::HtmlExtension

def html(attributes = {}) # :yield:

:yield:

html(if $VERBOSE then "PRETTY" end) { "HTML string" }

# = html("PRETTY" => " ") { "" }
html("PRETTY") { "" }

#
#
#
#
#
html("PRETTY" => "\t") { "" }

#
#
#
#
#
html("PRETTY" => " ") { "" }

# string
html("DOCTYPE" => '') { "string" }

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

# string
html("LANG" => "ja") { "string" }

# string
html{ "string" }

The body of the html element is supplied as a block.

should include the entire text of this tag, including angle brackets.
"DOCTYPE", if given, is used as the leading DOCTYPE SGML tag; it
a string as the sole argument to this method. The pseudo-attribute
HTML string should be indented. "PRETTY" can also be specified as
pseudo-attribute "PRETTY" can be used to specify that the generated
The attributes of the element are specified as a hash. The

Generate a top-level HTML element as a string.
def html(attributes = {}) # :yield:
  if nil == attributes
    attributes = {}
  elsif "PRETTY" == attributes
    attributes = { "PRETTY" => true }
  end
  pretty = attributes.delete("PRETTY")
  pretty = "  " if true == pretty
  buf = "".dup
  if attributes.has_key?("DOCTYPE")
    if attributes["DOCTYPE"]
      buf << attributes.delete("DOCTYPE")
    else
      attributes.delete("DOCTYPE")
    end
  else
    buf << doctype
  end
  buf << super(attributes)
  if pretty
    CGI.pretty(buf, pretty)
  else
    buf
  end
end