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 brackets.

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

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" }
doc_ruby_on_rails
2015-03-31 21:44:02
Comments
Leave a Comment

Please login to continue.