std/html/markup

std/html/src/markup.trb

Html, Markup and the pieces the generated element table writes with (docs/design/WEB.md section 4.2). A page is a list of pieces of text that is joined once; every piece that comes from a value was escaped on the way in, so there is no way from a String to a page that skips it.

type Html

type Html<Message = Never>

A page, or part of one, rendered: the pieces of its markup. Message is what the events of the page send; this step has no events, so it is a parameter only the type carries, and a page without events is an Html<Never>.

Examples

use fragment from "std/html"

const page = fragment {
  p "Hello"
}
print page.render()

fn render

fn render(): String

The markup as one text: the pieces joined once.

fn trusted

static fn trusted(file: EmbeddedText): Html<Never>

Markup the author put into the binary, inserted as it is: the only way to write raw markup. The file is trusted at build time exactly as std/resource trusts it; a String can not be, so a value never skips the escaping.

fn isEmpty

fn isEmpty(): Bool

Whether the page holds no markup at all.

type Markup

type Markup<Message = Never>

The receiver of the builder: the elements are its members (td "text", tr { ... }), and text writes text. A Markup is only ever handed to a block by fragment and document, which answer the Html it wrote.

fn text

var fn text(content: String)

Writes content as text: &, < and > are escaped.

fn include

var fn include(page: Html<Message>)

Writes a page that was built before, a component's answer or a fragment, at this place.