larzhtml
XSS-safe HTML builder.
Build HTML with automatic escaping of text and attribute values, void-element and boolean-attribute handling, and a Markup type for trusted fragments — safe by default.
larzscript pkg install html
What you get
- Auto-escapes text & attrs
- Void & boolean attributes
- Markup type for raw HTML
- XSS-safe by default
Try it
import "html" as html
print(html.el("a", {"href": "/x"}, "A & B"))
print(html.void_el("input", {"disabled": true, "type": "text"}))
let trusted = html.markup(html.tag("b", "bold"))
print(html.el("div", {}, trusted))Output
<a href="/x">A & B</a> <input disabled type="text"/> <div><b>bold</b></div>
Why it's in the Larz Stack
larzhtml is a real Larzscript package (larzscript pkg install html) - money-native, zero dependencies, the same language as the rest of the estate, not a separate Python runtime. It composes with the rest of the Larz Stack and the Larz framework.