For the complete documentation index, see llms.txt. This page is also available as Markdown.

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

<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

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

Template scope

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

Demo

Try the Template demo.

Last updated

Was this helpful?