Overview
Mates templates are lit-html tagged templates: html`…` returns a TemplateResult. On re-render, only the expressions that changed are patched in the live DOM — there is no virtual DOM tree.
Import html, nothing, and re-exported directives from mates. You do not add lit-html as a separate app dependency.
Binding prefixes
|
Syntax
|
Sets
|
Notes
|
|---|---|---|
${expr}
| Child / text |
Text, nested TemplateResult, arrays, primitives. Prefer nothing to clear.
|
attr=${val}
| HTML attribute | Pass null/undefined to remove. |
.prop=${val}
| DOM property | Use for .value, .checked, .disabled, etc. |
@event=${fn}
| Event listener | Stable across renders — equivalent to addEventListener. |
?attr=${bool}
| Boolean attribute | Present when true, removed when false. |
Dynamic expressions in html``
Embed any JavaScript expression inside ${...}. Mates
re-renders only the parts of the DOM that actually changed. Use
.value (dot prefix) for DOM property bindings and
@event for event listeners.
Clear a branch with nothing
Prefer nothing over an empty string when hiding a branch — it clears the child part cleanly without leftover nodes.