How template holes and updates work
mainIn uhtml, template holes are not just text interpolations; they are treated as specific nodes in the tree that can be updated.
When the parser encounters a hole (represented internally by a NUL character), it uses the update function to create a record. Depending on the context, holes can represent:
- TEXT: Interpolation within text content.
- ATTRIBUTE: Interpolation within an attribute (e.g.,
<div class="${val}">). If the attribute name ends with aNULcharacter, it is treated as a dynamic attribute update. - COMMENT: A placeholder comment node used to track the position of the hole.
- COMPONENT: A placeholder for a custom component.
The update function provides the path (an array of indices) to the specific location in the tree where the hole resides, allowing efficient targeted updates later.