// All-static subtrees of HTML literals and templates are one immortal // block in the native backend, shared by every evaluation (the C // backend's `tl_lit_c` blocks; `LOUISE_NO_STATIC_CTORS` rebuilds them). // Behaviour is unchanged: holes evaluate left to right, effects // included, and escaping is as ever — the interpreter, which rebuilds // the tree per call, prints the same. import std/html.{type Html} import std/io import std/template.{pug} effect log { fn log :: msg: String -> () } fn traced :: mark: String value: String -> String / { log mark value } fn traced_int :: mark: String value: Int -> Int / { log mark value } fn with_log :: action: fn() -> a / -> a / { handle { action () } with { log m -> io.println ("log: " <> m) } } // The attribute list and the subtree are all-static (hoisted); the // holes are not. Attributes lower before children, so the log reads // "attr", "first", "second". fn row :: n: Int a: String b: String -> Html / {

{traced "first" a}& static{traced "second" b}

} pub fn main :: -> () / { use <- with_log io.println (html.render (row 1 "x" "y")) // The same literal evaluated again: the static parts are shared, the // holes run again, in order. io.println (html.render (row 2 "x" "y")) // A pug template's static parts are the same statics (pug is compiled // to the literal's constructors, ADR 0057); its holes run in order. io.println ( html.render pug` .card h2 {traced "title" "T"} p {traced "body" "B"} ` ) } //> log: attr //> log: first //> log: second //>

x& staticy

//> log: attr //> log: first //> log: second //>

x& staticy

//> log: title //> log: body //>

T

B