Skip to main content

Quik Framework :: Templates

Offers template rendering with helpers. It depends on the HTTP module and registers default Handlebars helpers during setup.

Installation

npm install @quik/templates

Usage

Load templates and render:

import { TemplatesStore, QTemplate } from '@quik/templates';

await TemplatesStore.load('core', './templates');

class WelcomeTemplate extends QTemplate<{ name: string }> {
constructor(name: string) {
super('core.welcome', { name });
}
}

const output = new WelcomeTemplate('Quik').render();

TemplatesStore.load() loads templates into memory. If template files change on disk, call TemplatesStore.reload() to re-read templates, or clear() and load() to reset the store.

Configuration

Optional config flags:

  • templates.throwOnMissing: throw when a template key is missing (default: false).
  • templates.disableCache: re-read templates from disk on every get() (default: false).

Reloading & Partials

Template and partial names are stored as lowercase module.filename keys (for example core.email.welcome). Partials follow the same naming convention and must be loaded through PartialsStore.load(). When hot-reloading in development, clear and reload partials before rendering templates so that new partial contents are registered with Handlebars.

API Highlights

  • QTemplate base class for rendering templates.
  • TemplatesStore.load(), .get(), and .clear() for template discovery.
  • HelpersStore and PartialsStore for Handlebars helpers/partials (use PartialsStore.clear() before reloading).

Testing & Coverage

See the root instructions for details on running pnpm run test:coverage and accessing coverage artifacts.

API Reference

Generated API documentation is available in the templates API section.