> For the complete documentation index, see [llms.txt](https://docs.fact-finder.com/llms.txt). Markdown versions of documentation pages are available by appending `.md` to page URLs; this page is available as [Markdown](https://docs.fact-finder.com/webcomponents-overview/api/more-features/template.md).

# Template

\`ff-template\` renders custom markup from a selected FactFinder response or supplied data. Use \`scope\` for endpoint responses or set \`data\` through JavaScript.

## Documentation

### Subscribing to an endpoint

Set the `scope` attribute to make `ff-template` subscribe to the specified endpoint.

```html
<ff-template scope="SearchAndNavigation">{{totalHits}} results found.</ff-template>
```

Available values for `scope` are:

* `CampaignPage`
* `CampaignProduct`
* `CampaignShoppingCart`
* `Compare`
* `Navigation`
* `NavigationCategory`
* `PredictiveBasket`
* `Recommendation`
* `Records`
* `Search`
* `Similar`
* `Suggest`
* `SearchAndNavigation` (special scope)

These values mirror the supported FactFinder API endpoints. They are also available for subscribing in the `factfinder.response` namespace.

Only `CampaignRedirect` is not available to `ff-template`.

`SearchAndNavigation` is a special scope that makes `ff-template` simultaneously listen to *Search* and *Navigation* responses. Both endpoints have a very similar purpose, and they return the same data structure. With this scope, you can use one HTML template for search result pages and category pages.

{% hint style="info" %}
`SearchAndNavigation` is likely the most useful scope.
{% endhint %}

### Passing custom data without subscribing

`ff-template` has a `data` property which you can access through JavaScript. This property takes any type of data.

```html
<script>
    function populateTemplates() {
        const text = `This is some text.`;

        const ffTemplate1 = document.querySelector(`#demoTemplate1`);
        const ffTemplate2 = document.querySelector(`#demoTemplate2`);
        const ffTemplate3 = document.querySelector(`#demoTemplate3`);

        ffTemplate1.data = text;
        ffTemplate2.data = { text };
        ffTemplate3.data = { nested: { text } };
    }
</script>

<button onclick="populateTemplates()">Set data</button>

<ff-template id="demoTemplate1">
    Direct access of 'data' property: {{.}}
</ff-template>

<ff-template id="demoTemplate2">
    Accessing object member: {{text}}
</ff-template>

<ff-template id="demoTemplate3">
    Accessing nested data: {{nested.text}}
</ff-template>
```


---

# Agent Instructions
This documentation is published with GitBook. GitBook is the documentation platform designed so that both humans and AI agents can read, navigate, and reason over technical content effectively. Learn more at gitbook.com.

## Querying This Documentation
If you need additional information that is not directly available in this page, you can query the documentation by asking a question.

Perform an HTTP GET request on the following URL with the `ask` and `goal` query parameters:

```
GET https://docs.fact-finder.com/webcomponents-overview/api/more-features/template.md?ask=<question>&goal=<user_goal>
```

`ask` is the immediate question: it should be specific, self-contained, and written in natural language.
`goal` is what the user is ultimately trying to achieve, the reason they need the answer. Sharing it helps GitBook give you a better, more relevant answer. A goal is most helpful when it describes the outcome the user wants rather than restating the question. For example, with `ask=how do I create an API token`, a goal like `automate deployments from our CI pipeline` lets GitBook tailor the answer to that use case.

The response will contain a direct answer to the question and relevant excerpts and sources from the documentation.

Use this mechanism when the answer is not explicitly present in the current page, you need clarification or additional context, or you want to retrieve related documentation sections.
