Are you an LLM? You can read better optimized documentation at /directives/lu-text.md for this page in Markdown format
lu-text
lu-text updates the element's text content. It is a one-way binding from a reactive property to the DOM.
Basic Usage
html
<div lu-scope="{ msg: 'Hello' }">
<span lu-text="msg"></span>
</div>Comparison with Mustache Syntax
lu-text is equivalent to using mustache interpolations ({{ }}).
html
<span lu-text="msg"></span>
<!-- is the same as -->
<span>{{ msg }}</span>Why use lu-text?
While mustache syntax is generally more flexible, lu-text can be useful in specific cases:
- Avoiding FOUC: When using mustache syntax, the raw
{{ msg }}may be visible for a split second before Lune initializes. Usinglu-texton an empty element avoids this flash of uncompiled content (you can also uselu-cloakto solve this). - Overwriting Content:
lu-textwill completely overwrite all children inside the target element, whereas mustache syntax allows you to combine static text and reactive data within a single element.
Details
lu-text works by setting the element's textContent property. This means all values are treated as plain text and will not be interpreted as HTML.
Values are stringified the same way mustache interpolation stringifies them: null and undefined render as an empty string, and objects and arrays are rendered as indented JSON, which is handy while debugging a scope.
html
<div lu-scope="{ msg: '<b>Bold</b>' }">
<!-- Renders as: <b>Bold</b> -->
<span lu-text="msg"></span>
</div>