interface / @typed/template/HtmlChunk

HtmlPartChunk

A chunk representing a dynamic part (interpolation).

Package version
1.0.0-beta.7
Category
Dynamic HTML chunks
Since
1.0.0

Import

import { HtmlPartChunk } from "@typed/template/HtmlChunk";

Signatures

export interface HtmlPartChunk {
    readonly _tag: "part";
    readonly node: Template.PartNode;
    readonly render: (value: unknown) => string;
}

Why

The parsed part and its context-aware serializer stay together, avoiding a generic raw-HTML interpolation path.

Ownership and lifetime

The record borrows the parsed node and pure serializer; evaluation belongs to the HTML-rendering Fx.

Property: _tag

Identifies a single dynamic part chunk.

Property: _tag: Why

Enables exhaustive renderer dispatch.

Property: _tag: Ownership and lifetime

Immutable metadata owned by the chunk.

Property: node

The parsed dynamic part whose index selects the input value.

Property: node: Why

Preserves the exact HTML context for serialization.

Property: node: Ownership and lifetime

The chunk borrows the immutable AST node.

Property: render

Function to render the value of this part into a string.

Property: render: Why

Each part keeps its context-specific escaping function.

Property: render: Ownership and lifetime

The pure function retains no application value between calls.

Examples

import { templateToHtmlChunks, type HtmlPartChunk } from "@typed/template/HtmlChunk"
import { parse } from "@typed/template/Parser"

const chunk = templateToHtmlChunks(parse(["<p>", "</p>"]))[1] as HtmlPartChunk

Other public imports

These import paths expose the same declaration. Each page retains its own public name and signature.

Source