html

JavaScript template literals for constructing DOM nodes from HTML

API

fragmentFrom constant

A JavaScript template string literal that returns an HTML document fragment.

Example:

const fragment = fragmentFrom.html`Hello, <em>world</em>.`

returns a DocumentFragment whose innerHTML is Hello, <em>world</em>.

This function is called html so that it can be easily used with HTML syntax-highlighting extensions for various popular code editors.

See also templateFrom.html, which returns a similar result but as an HTMLTemplateElement.

templateFrom constant

A JavaScript template string literal that returns an HTML template.

Example:

const myTemplate = templateFrom.html`Hello, <em>world</em>.`

returns an HTMLTemplateElement whose innerHTML is Hello, <em>world</em>.

This function is called html so that it can be easily used with HTML syntax-highlighting extensions for various popular code editors.

See also html, a helper which returns a similar result but as an DocumentFragment.