Assigns¶
Key-value store with change tracking for LiveView state.
Values are stored as TemplateValue via the templates library's
TemplateValues container. Plain strings are automatically wrapped.
The framework checks changed() after each event handler to determine
whether a re-render is needed, and calls clear_changes() after rendering.
Constructors¶
create¶
Returns¶
- Assigns ref^
Public Functions¶
update¶
Set a value and mark assigns as changed.
Parameters¶
- key: String val
- value: (String val | TemplateValue box)
Returns¶
- None val
apply¶
Look up a value by key.
Parameters¶
- key: String val
Returns¶
- TemplateValue box ?
changed¶
True if any assign was modified since the last clear_changes().
Returns¶
- Bool val
clear_changes¶
Reset change tracking. Called by the framework after rendering.
Returns¶
- None val
template_values¶
Return the backing TemplateValues for use with HtmlTemplate.render()
or HtmlTemplate.render_to().
Returns¶
- TemplateValues box
component_html¶
Look up the rendered HTML for a registered component.
Use this in render() or render_parts() to include component output in the parent's
HTML. The returned string is already escaped by the component's own
HtmlTemplate -- insert it as TemplateValue.unescaped() in the
parent's template values.
Parameters¶
- id: String val
Returns¶
- String val ?
render_values¶
Create a writable child scope of the backing template values.
Use this in render() or render_parts() to overlay component HTML or computed values
onto the existing assigns without modifying the underlying state.
The child scope falls through to the parent for lookups, so all
existing assigns remain accessible.
Returns¶
- TemplateValues ref