Templates
function htmlSource
Interprets a template literal as an HTML template that can efficiently render to and update a container.
Import
import { html } from 'lit-html';
Signature
html(strings, values): TemplateResult
Parameters
- strings
TemplateStringsArray- values
Array<unknown>
value nothingSource
A sentinel value that signals a NodePart to fully clear its content.
Import
import { nothing } from 'lit-html';
Type
symbolfunction renderSource
Renders a template result or other value to a container.
Import
import { render } from 'lit-html';
Signature
render(result, container, options?): void
Parameters
- result
-
unknownAny value renderable by NodePart - typically a TemplateResult created by evaluating a template tag like
htmlorsvg. - container
-
Element | DocumentFragmentA DOM parent to render to. The entire contents are either replaced, or efficiently updated if the same result type was previous rendered there.
- options?
-
Partial<RenderOptions>RenderOptions for the entire render tree rendered to this container. Render options must not change between renders to the same container, as those changes will not effect previously rendered DOM.
Details
To update a container with new values, reevaluate the template literal and call render with the new result.
function svgSource
Interprets a template literal as an SVG template that can efficiently render to and update a container.
Import
import { svg } from 'lit-html';
Signature
svg(strings, values): SVGTemplateResult
Parameters
- strings
TemplateStringsArray- values
Array<unknown>
class SVGTemplateResultSource
A TemplateResult for SVG fragments.
Import
import { SVGTemplateResult } from 'lit-html';
Details
This class wraps HTML in an <svg> tag in order to parse its contents in the SVG namespace, then modifies the template to remove the <svg> tag so that clones only container the original fragment.
Methods and properties
new SVGTemplateResult(strings, values, type, processor): SVGTemplateResult
Parameters
- strings
TemplateStringsArray- values
ReadonlyArray<unknown>- type
string- processor
TemplateProcessor
readonly processor: TemplateProcessorSource
readonly strings: TemplateStringsArraySource
readonly type: stringSource
readonly values: ReadonlyArray<unknown>Source
getHTML(): stringSource
Returns a string of HTML used to create a <template> element.
getTemplateElement(): HTMLTemplateElementSource
class TemplateResultSource
The return type of html, which holds a Template and the values from interpolated expressions.
Import
import { TemplateResult } from 'lit-html';
Methods and properties
new TemplateResult(strings, values, type, processor): TemplateResultSource
Parameters
- strings
TemplateStringsArray- values
ReadonlyArray<unknown>- type
string- processor
TemplateProcessor
readonly processor: TemplateProcessorSource
readonly strings: TemplateStringsArraySource
readonly type: stringSource
readonly values: ReadonlyArray<unknown>Source
getHTML(): stringSource
Returns a string of HTML used to create a <template> element.
getTemplateElement(): HTMLTemplateElementSource
type RenderOptionsSource
Import
import { RenderOptions } from 'lit-html';
© Google LLC
Licensed under the Creative Commons Attribution 3.0 Unported License.
https://lit.dev/docs/v1/api/lit-html/templates/