import std/html.{type Element, type Html} import std/list import std/template.{type Hole, type Template, Template, Text, html, pug, xml} // std's `html` compiles the template to the tree (ADR 0057): an // `Element`, its holes typed by position. fn para :: name: String { html`

{name}

` } //~ TYPE para: fn(String) -> Element fn shown :: n: Int -> Html { html`

{n}

` } fn debugged :: n: Int -> Html { html`
{n:?}
` } fn embed :: body: Html -> Html { html`
{body}
` } fn embed_list :: items: List -> Html { html`` } fn xml_doc :: name: String { xml`{name}` } //~ TYPE xml_doc: fn(String) -> Xml fn pug_card :: title: String { pug`.card h2 {title}` } //~ TYPE pug_card: fn(String) -> Element
pub fn no_show :: f: fn(Int) -> Int -> Html { html`

{f}

` //~ ERROR E0401 does not implement `Show` } pub fn unknown_tag :: -> Html { puug`.card` //~ ERROR E0101 no value named `puug` } pub fn tag_not_a_function :: -> () { let x = 42 x`nope` //~ ERROR E0207 this is not a function } // std's templaters are syntax, not values (ADR 0057): outside a // template's tag position they do not exist as values. pub fn pug_as_value :: -> () { let t = pug //~ ERROR E0605 syntax, not values } pub fn html_as_value :: templates: List> -> List { list.map templates html //~ ERROR E0605 syntax, not values } pub fn xml_qualified_as_value :: -> () { let x = template.xml //~ ERROR E0605 syntax, not values } // A local shadowing a templater is an ordinary value. pub fn shadowed :: -> Int { let pug = 42 pug } // A custom templater is any function from a `Template`. pub fn shout :: template: Template //~ WARN W0101 shadows the imported module -> String { let Template(_, holes) = template match holes { [Text(s), ..] -> s, _ -> "!" } } pub fn custom :: -> String { shout`a {"bee"} c` }