type-alias / @typed/template/HtmlChunk

HtmlChunk

Represents a piece of a pre-compiled HTML template.

Chunks allow the renderer to stream static parts of the HTML immediately while waiting for dynamic parts to be resolved.

Package version
1.0.0-beta.13
Category
HTML chunk protocol
Since
1.0.0

Import

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

Signatures

export type HtmlChunk = HtmlTextChunk | HtmlPartChunk | HtmlSparsePartChunk;

Why

Chunks separate immediately writable author markup from dynamic work, which lets the HTML renderer preserve template order while remaining push-based.

Ownership and lifetime

Chunks are immutable rendering descriptions. The Fx that evaluates them owns subscriptions; the response sink owns emitted strings.

Examples

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

const template = parse(["<div>Hello ", "</div>"])
const chunks = templateToHtmlChunks(template)

// chunks will contain:
// - HtmlTextChunk with text "<div>Hello "
// - HtmlPartChunk for the dynamic part
// - HtmlTextChunk with text "</div>"

Other public imports

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

Source