html

Template literal function that creates reactive DOM elements with automatic updates.

Signature

function html(template: TemplateStringsArray, ...values: TemplateValue[]): Node;

Parameters

  • template: TemplateStringsArray - Template string array from template literal

  • ...values: TemplateValue[] - Interpolated values in the template

Returns

  • Node - A DOM node containing the rendered elements

Type Definition

type PrimitiveValue = string | number | boolean;
type TemplateValue =
  | PrimitiveValue
  | Node
  | Signal
  | ((e: Event) => void)
  | (() => TemplateValue);

Example

Advanced Usage

Idioms and Patterns: Advanced Template Features

Binding Types

The html function supports different types of bindings:

Performance Notes

  • Templates are cached using WeakMap for efficient re-use

  • Only binding values are updated when signals change, not the entire template

  • Direct DOM manipulation for optimal performance

  • No Virtual DOM overhead

Last updated