std/html/html
std/html/src/html.trb
fragment and document: the two ways a block of markup becomes an Html, and the script element, which takes
a file of the package and never a String.
fn fragment
fn fragment(children: (var self: Markup<Never>) => Void): Html<Never>
The markup the block writes, without a document around it: a part of a page, a component, the answer to a request for a piece of one.
Examples
const list = fragment {
ul {
li "one"
li "two"
}
}
assert(list.render() == "<ul><li>one</li><li>two</li></ul>")
fn document
fn document(title: String, lang: String = "en", children: (var self: Markup<Never>) => Void = {}): Html<Never>
A whole page: <!doctype html>, then html with the language, a head with the character set, the viewport and
the title, and a body that holds what the block writes.
Examples
const page = document title: "Orders", lang: "en" {
h1 "Orders"
}
print page.render()
extend Markup<Message>
extend<Message> Markup<Message>
The one element that is written by hand: script, whose source can not be a String.
fn script
var fn script(source: Resource, kind: String? = None, defer: Bool = false)
A script of the package, linked by the name of its file. Only a Resource can be a script: a String cannot, so
a page never carries script text that came from a value. Until assets get their fingerprinted URLs (WEB slice 5)
the link is the file's stable name.
fn style
var fn style(sheet: EmbeddedText)
A style sheet of the package, written into the page as the text of a style element. Only an EmbeddedText can be
one: a String cannot, so a page never carries style text that came from a value.