<!-- This file is auto-generated by the docs:generate-viewhelper-docs command. Do not edit directly -->

# ui:template

**Reference:** [View Source](https://github.com/jramke/fluid-primitives/tree/main/Classes/ViewHelpers/TemplateViewHelper.php)

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.

```html
<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`](/docs/client-utilities/template.md) 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}"`.

## Set the context

`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.

## Arguments

| Name | Type | Description | Required | Default |
|------|------|-------------|----------|--------|
| `name` | string | Ref name for the wrapping `&lt;template&gt;` element, camelCase (e.g. &quot;itemTemplate&quot;) like `ui:ref`&#039;s own `name` argument. | Yes | - |
| `context` | string | camelCase base name of the enclosing component this template belongs to, e.g. &quot;fileUpload&quot;. 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&#039;s own template body. | No | '' |
