Skip to content
Verified

Runtime directives

The full xu-* directive vocabulary Slim and the platform runtime share.

Directives are how Slim turns plain markup, or runtime nodes, into a reactive Xuda surface. The whole authoring vocabulary is 19 attributes plus two suffixed families.

State and output

Expressions

xu-exp:* evaluates an expression against field values and applies the result to <attr>. It works for plain HTML attributes and for xu-* attributes alike.

html
<div xu-exp:xu-content="'Hello ' + @first_name"></div>
<div xu-exp:class="@is_active ? 'text-green-500' : 'text-gray-500'"></div>
xu-exp:class replaces, it doesn't merge

xu-exp:class replaces the static class attribute entirely rather than merging with it. If you need both, put the static classes inside the expression, or use xu-class for the conditional part and leave class alone.

Iteration and conditional rendering

Use xu-show when the node should remain mounted and just hide, and xu-render when it should be removed from the live DOM when false.

Events and workflows

xu-on:<event> always takes an array of handler objects, each carrying a workflow:

html
<button
  xu-on:click='[
    { "handler": "custom", "workflow": [
      { "data": { "action": "update", "name": { "value": "@count_v: @count_v + 1" }, "enabled": true } }
    ] }
  ]'
>
  Increment
</button>

Eight shorthand attributes normalize into full xu-on:* workflows for simple field updates, so a value like xu-click="count++" works with no handler JSON: xu-click, xu-dblclick, xu-contextmenu, xu-focus, xu-keyup, xu-change, xu-blur, xu-init.

Advanced directives

Ordering

Attributes run in phases per element. xu-cdn, xu-style, xu-render, xu-for-key and xu-for-val run before the node is built; xu-bind, xu-class, xu-script, xu-ui-plugin and xu-ref run after it. That ordering is why an xu-cdn resource is already available to an xu-script on the same element.

Reserved field names

Nine names must never be used as a field id, because the runtime assigns them during iteration and context resolution: _NULL, _THIS, _FOR_KEY, _FOR_VAL, _ROWNO, _ROWID, _ROWDOC, _KEY, _VAL.

Practical rule

Use the smallest directive that matches the need: xu-text or xu-content for simple output, xu-click for a simple update, xu-on:* for full workflow logic, xu-exp:* for computed attributes, and xu-for / xu-render / xu-show for structural behavior.

xu-if and the sibling chain are not here

xu-if, xu-else-if and xu-else belong to the reactive renderer, shipped in the full platform bundle only. Neither Slim nor the CLI's bundled runtime carries the reactive engine, so use xu-render or xu-show with an expression on each branch instead. xu-route and xu-prog are not directives at all: they appear on marketing material but have no handler anywhere in the runtime.