Skip to content
Manolo Cantón edited this page Aug 19, 2024 · 5 revisions

Documents

HTMLDocument creates a simple HTML document using chain methods. Tags are added in the order they are called.

Note: It still does not format reserved characters in HTML.

  • add_doctype() adds the doctype: <!DOCTYPE hmtl>. It should always be called at the beginning.
  • add_comment() adds a comment: <!-- My comment -->.
  • add_text() adds text. Example: doc.start_p().add_text("My paragraph.").close_tag().
  • add_tag() adds an inline tag: <input type="text" value="apple">. Some additional add_* methods have been added to add specific tags.
  • start_tag() opens a block tag: <h2>. Some additional start_* methods have been added to add specific tags.
  • close_tag() closes an open block tag: </h2>.

Simple Document

var doct := HTMLDocument.new()
doc.add_doctype().start_html({
	lang = "en",
}) \
	.start_head() \
		.add_meta({ charset = "UTF-8" }) \
	.close_tag() \
	.start_body() \
		.start_p() \
			.add_text("Hello world!") \
		.close_tag() \
	.close_tag() \
.close_tag()

Writing utils

  • newline() starts a newline in code. Do not confuse with <br>.
  • backspace() erases the last character.
Clone this wiki locally