LearnTemplate directives

Template Directives #

Use directives to bind state and control which HTML renders. They are template syntax, not JavaScript expressions or custom elements you register yourself.

<if condition="items.length">
  <ul>
    <for each="item in items">
      <li>{{item.name}}</li>
    </for>
  </ul>
</if>

Available Directives #

Choose the directive for the task:

How Directives Work #

The build validates directives and compiles them for the native renderer. The renderer evaluates them against request state without executing application JavaScript. In an interactive component, the browser framework also updates bindings, conditions, and loops when state changes.

Text bindings read paths only. Conditions and boolean attributes support the documented expression subset, not arbitrary JavaScript.