-
-
Notifications
You must be signed in to change notification settings - Fork 1
HTML
Manolo Cantón edited this page Aug 19, 2024
·
5 revisions
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 additionaladd_*
methods have been added to add specific tags. -
start_tag()
opens a block tag:<h2>
. Some additionalstart_*
methods have been added to add specific tags. -
close_tag()
closes an open block tag:</h2>
.
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()
-
newline()
starts a newline in code. Do not confuse with<br>
. -
backspace()
erases the last character.