Recipes
Register a custom Handlebars helper
import { HelpersStore } from '@quik/templates';
HelpersStore.load('uppercase', (value: string) => value.toUpperCase());
Helpers registered with HelpersStore.load(name, callback) are applied to the shared Handlebars instance
alongside handlebars-layouts, which is registered automatically during module setup.
Load and use partials
import { PartialsStore, TemplatesStore } from '@quik/templates';
await PartialsStore.load('core', './templates/partials');
await TemplatesStore.load('core', './templates');
Partials are keyed the same way as templates (module.filename, lowercased) and must be loaded before rendering
any template that references them with {{> module.filename}}.
Hot-reload templates and partials in development
import { PartialsStore, TemplatesStore } from '@quik/templates';
PartialsStore.clear();
await PartialsStore.load('core', './templates/partials');
TemplatesStore.reload();
Clear and reload partials before rendering so new partial contents are registered with Handlebars; use
TemplatesStore.reload(templateName) to refresh a single template instead of the whole store.
Fail fast on missing templates
Set templates.throwOnMissing to true in non-production environments to catch typo'd template names early —
TemplatesStore.get() throws a plain Error instead of logging a warning and returning an empty string.