Skip to main content

ui:template

View as Markdown

Wraps markup in a <template> that the client clones for content the server does not have yet, such as async search results, previews of uploaded files or the rows of a recurring field.

<ui:combobox.root>
  ...
  <ui:combobox.content>
    <ui:combobox.list>
      <ui:template name="itemTemplate" context="combobox">
          <ui:combobox.item>
              <span {ui:ref(name: 'title')}></span>
          </ui:combobox.item>
      </ui:template>
    </ui:combobox.list>
  </ui:combobox.content>
</ui:combobox.root>

Clone the template and fill its ui:ref parts with the Template client utility. Inside it, ui:ref works as in a component's own template, and components such as ui:combobox.item render as part of the template without extra props.

name is the ref name of the <template> element: itemTemplate renders data-combobox-item-template="{rootId}".

context is the camelCase name of the enclosing component. Pass it when the template is slot content of another component, as above. That includes the plain Fluid template of a content element. Omit it in the template body of a component, where it defaults to the active component. A native <template> element is enough for a one-off client-rendered list that has no enclosing component.

Name Type Description Required Default
name string Ref name for the wrapping &lt;template&gt; element, camelCase (e.g. "itemTemplate") like ui:ref's own name argument. Yes -
context string camelCase base name of the enclosing component this template belongs to, e.g. "fileUpload". Required when this ui:template is slot content passed into another component or sits in a plain Fluid template. Defaults to the active component when written directly inside a component's own template body. No ''