Handlebars

Handlebars is a JavaScript templating library. It compiles markup with placeholders into a render function, which keeps HTML out of imperative code. On a storefront it earns its place wherever results arrive as JSON instead of as Liquid-rendered HTML, because something still has to turn that JSON into the same cards the server would have sent.

Documented at https://handlebarsjs.com/.

How We've Used It

Search is where that happens. When results come back as data, the rendering has to move to the client, and string concatenation stops being maintainable at about the second card variant. A compiled template keeps the markup readable, in one place, and close enough to the Liquid that renders the same card server-side that the two can be kept in agreement. The pattern is a template per result shape, hydrated per response, with the empty and loading states written as their own templates rather than as branches inside another one.

Builds Using It

One further gated build uses it; its page follows.

Related Entities

Our Role

Integration. We author the templates; the library is open source and stays as published.

Builds