> 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/web-components-4.x./api/more-features/template.md).

# Template

Bind FactFinder data to markup with Mustache templates.

## Documentation

### Summary

Use `ff-template` to understand FactFinder Web Components data binding. Set a data model to update the view. Access values with Mustache syntax, `{{ }}`.

**Simple data**

```html
<script>
    function setTemplate1() {
        const template1 = document.querySelector("#demoTemplate1");
        template1.data = { test: "This is my Test Data" };
    }
</script>
<p>Set simple data into a Template</p>
<button onclick="setTemplate1()">Set simple Data</button>
<ff-template id="demoTemplate1">
    {{test}}
</ff-template>
```

**Complex data**

```html
<script>
    function setTemplate2() {
        const tmp = document.querySelector("#demoTemplate2");
        tmp.data = {
            product: {
                name: "Super awsome Product",
                description: "This Product is super awsome! Go buy it!",
                info: { rating: 5, price: 100, currency: "€" }
            }
        };
    }
</script>
<p>Set complex data into a Template</p>
<button onclick="setTemplate2()">Set complex Data</button>
<ff-template id="demoTemplate2">
    <h2>Name: {{product.name}}</h2>
    <p>{{product.description}}</p>
    <strong>{{product.info.price}} {{product.info.currency}}</strong>
    <p>Rating: {{product.info.rating}}/5</p>
</ff-template>
```

**Raw HTML**

Use triple braces for raw HTML from FactFinder, such as campaign feedback.

```html
<ff-template id="demoTemplate3">
    <!-- Renders the value as a string. -->
    {{product.image}}
    <!-- Renders the value as HTML. -->
    {{{product.image}}}
</ff-template>
```

### Template scope

Set `scope="result"` to use a search response as the template model.

```html
<ff-communication url="https://web-components.fact-finder.de/FACT-Finder"
                  version="ng"
                  api="v5"
                  channel="bergfreunde-de"
                  default-query="tasche"
                  search-immediate></ff-communication>

<ff-searchbox><input /></ff-searchbox>
<ff-searchbutton><button>Search</button></ff-searchbutton>

<ff-template id="demoTemplate4" scope="result">
    <h2>Search Result:</h2>
    <p>resultCount: {{resultCount}}</p>
    <p>searchTime: {{searchTime}}</p>
</ff-template>
```

## Demo

Try the [Template demo](https://search-web-components.fact-finder.de/demos/4.x/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/web-components-4.x./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.
