function / @typed/template/Wire

toHtml

Converts a Rendered value to an HTML string.

Package version
1.0.0-beta.13
Category
DOM serialization
Since
1.0.0

Import

import { toHtml } from "@typed/template/Wire";

Signatures

export declare function toHtml(node: Rendered): string;

Why

DOM integrations can expose a diagnostic/string representation while preserving their concrete nodes for DOM consumers.

Ownership and lifetime

Serialization reads the current DOM and neither moves nor retains nodes. It is not the streaming SSR renderer and does not sanitize existing markup.

Examples

import { toHtml } from "@typed/template/Wire"

const div = document.createElement("div")
div.textContent = "Hello"
const html = toHtml(div) // "<div>Hello</div>"

const fragment = document.createDocumentFragment()
fragment.appendChild(div)
const fragmentHtml = toHtml(fragment) // "<div>Hello</div>"

Other public imports

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

Source