# lit-html **Repository Path**: mirrors_developit/lit-html ## Basic Information - **Project Name**: lit-html - **Description**: HTML template literals in JavaScript - **Primary Language**: Unknown - **License**: BSD-2-Clause - **Default Branch**: master - **Homepage**: None - **GVP Project**: No ## Statistics - **Stars**: 0 - **Forks**: 0 - **Created**: 2020-08-08 - **Last Updated**: 2026-08-01 ## Categories & Tags **Categories**: Uncategorized **Tags**: None ## README # lit-html HTML templates, via JavaScript template literals [![Build Status](https://travis-ci.org/PolymerLabs/lit-html.svg?branch=master)](https://travis-ci.org/PolymerLabs/lit-html) ## Overview `lit-html` lets you write [HTML templates](https://developer.mozilla.org/en-US/docs/Web/HTML/Element/template) with JavaScript [template literals](https://developer.mozilla.org/en-US/docs/Web/JavaScript/Reference/Template_literals), and efficiently render and _re-render_ those templates to DOM. `lit-html` provides two main exports: * `html`: A JavaScript [template tag](https://developer.mozilla.org/en-US/docs/Web/JavaScript/Reference/Template_literals#Tagged_template_literals) used to produce a `TemplateResult`, which is a container for a template, and the values that should populate the template. * `render()`: A function that renders a `TemplateResult` to a DOM container, such as an element or shadow root. ### Examples `lit-html` can be used standalone and directly to help manage DOM: ```javascript const helloTemplate = (name) => html`
Hello ${name}!
`; // renders
Hello Steve!
to the document body render(helloTemplate('Steve'), document.body); // updates to
Hello Kevin!
, but only updates the ${name} part render(helloTemplate('Kevin'), document.body); ``` But it may also be common to use `lit-html` with a component system that calls `render()` for you, similar to React components: _(this example uses JS Class Fields, an upcoming specification)_ ```javascript class MyElement extends CoolLitMixin(HTMLElement) { static observedProperties = ['title', 'body']; title = `About lit-html`; body = `It's got potential.`; // Called by the base-class when properties change, result is passed // to lit-html's render() function. render() { return html`

${this.title}

${this.body}

`; } } ``` ## Motivation `lit-html` has four main goals: 1. Efficient updates of previously rendered DOM. 2. Expressiveness and easy access to the JavaScript state that needs to be injected into DOM. 3. Standard JavaScript without required build steps, understandable by standards-compliant tools. 4. Very small size. ## How it Works `lit-html` utilizes some unique properties of HTML `