Import
import { parse } from "@typed/template";Signatures
export declare function parse(template: ReadonlyArray<string>): Template.Template;Why
One renderer-neutral AST gives DOM rendering, SSR, and hydration the same interpolation paths and template hash. Template syntax remains ordinary HTML with explicit prefixes for properties, events, booleans, data, spreads, and refs.
Ownership and lifetime
The parser reuses internal scratch storage synchronously but returns a fresh, caller-owned immutable model on every call. Render layers decide whether and how long to cache compiled results by template-literal identity.
Errors and trust
Malformed author templates throw parser errors during compilation. Parsing does not sanitize markup; dynamic values are escaped later by the HTML renderer according to the recorded part context.
Examples
import { parse } from "@typed/template/Parser"
// Each array boundary records one interpolation point. Runtime values are
// supplied later by a renderer, not passed to parse.
const template = parse([
"<div id=\"",
"\" class=\"container\"><p>Hello, ",
"!</p></div>"
])
// Access parsed structure
console.log(template.nodes) // Array of parsed nodes
console.log(template.parts) // Array of dynamic interpolation points
console.log(template.hash) // Unique hash for the templateOther public imports
These import paths expose the same declaration. Each page retains its own public name and signature.