v0.6.22

Text Binding

Last updated


This page covers writing data into text with {{ }} and inserting HTML with :html.

{{ value }}


  1. <div id="app">
  2. <h1>{{ title }}</h1>
  3. <p>{{ user.name }} · {{ LENGTH(items) }} items</p>
  4. </div>
  5. <script>
  6. const app = new QUI({
  7. id: "app",
  8. data: { title: "QuickUI", user: { name: "Pardn" }, items: [1, 2, 3] },
  9. });
  10. </script>
Live preview · @pardnchiu/quickui@0.6.22

RuleDescription
Allowed charactersLetters, digits, underscores and .; may be wrapped in a built-in function
WhitespaceBoth {{title}} and {{ title }} work
Missing value{{ title }} stays on the page as written
Localization{{ i18n.key }} reads the current locale, see i18n
PositionReplaced only in text nodes; {{ }} inside plain attributes is left alone, use Attribute Binding for attributes

:html


  1. <div id="app">
  2. <section :html="content"></section>
  3. </div>
  4. <script>
  5. const app = new QUI({
  6. id: "app",
  7. data: { content: "<b>bold</b> text" },
  8. });
  9. </script>
Live preview · @pardnchiu/quickui@0.6.22

:html writes the value to innerHTML; when no matching data exists, the attribute value itself is written. Content is not sanitized, so never pass unescaped user input, or the page is open to XSS.
中文