v0.6.22

Render Shorthand

Last updated


This page covers the shorthand string format returned by the render option, and which directives it can and cannot express.

Format


  1. tag#id.class1.class2(key: "value", key2: "value")[ children ]

PartDescription
tagTag name, required
#id, .classOptional; multiple classes allowed
( ... )Attributes, key: "value" separated by commas or whitespace
[ ... ]Children: nested elements or double-quoted text, may span lines
"text"Parsed with innerHTML, so HTML entities work

  1. <div id="app"></div>
  2. <script>
  3. const app = new QUI({
  4. id: "app",
  5. data: { title: "QuickUI", link: "https://quickui.pardn.io" },
  6. event: { open: () => {} },
  7. render: () => `
  8. section.hero[
  9. h1[ "{{title}}" ]
  10. a(q-href: "link", qe-click: "open")[ "Docs" ]
  11. ]
  12. `,
  13. });
  14. </script>
Live preview · @pardnchiu/quickui@0.6.22

Whitespace


All whitespace inside double quotes is removed, attribute values included. Use an HTML entity when you need a space:
  1. p[ "Hello World" ]
  2. p[ "Hello&#32;World" ]

The first line renders HelloWorld and the second renders Hello World.

Available Directives


Attribute names only accept letters, digits, - and _, so directives starting with : or @ cannot be written.
FeatureShorthand form
Text interpolation"{{title}}"
Attribute bindingq- prefix, for example q-href, q-html, q-hide
Eventsqe- prefix, for example qe-click
:for, :if, :model, <temp :path>Not supported

For loops or conditions, use id with an HTML template instead.
中文