Function fromLiquidTemplate

  • Render a liquid template into a container

    Type Parameters

    Parameters

    • template: string

      Liquid template

    Returns ((container: HTMLElement, state: State) => PromiseLike<void>)

    Render function

      • (container, state): PromiseLike<void>
      • Parameters

        • container: HTMLElement
        • state: State

        Returns PromiseLike<void>

    import { fromLiquidTemplate } from "@nosto/autocomplete/liquid";

    const render = fromLiquidTemplate(`
    <div>
    <h1>{{title}}</h1>
    <ul>
    {% for product in products %}
    <li>{{product.name}}</li>
    {% endfor %}
    </ul>
    </div>
    `);

    render(document.getElementById("container"), {
    title: "My Title",
    products: [
    { name: "Product 1" },
    { name: "Product 2" },
    { name: "Product 3" }
    ]
    });