← All @molecule/* packages · App templates

@molecule/api-templating-handlebars

Provider bond · templating · API (Node) · v1.0.1 · Apache-2.0

Handlebars template provider for molecule.dev

npm install @molecule/api-templating-handlebars

npm · Source on GitHub · Implements @molecule/api-templating

How it works

@molecule/api-templating-handlebars is a provider bond on the API (Node) side: it implements the templating core interface (@molecule/api-templating) with a concrete vendor or library behind it.

Your code calls the core; you wire this provider once at startup. Swapping vendors later is one line in that wiring, not a rewrite.

import { setProvider } from '@molecule/api-templating'
import { provider } from '@molecule/api-templating-handlebars'

setProvider(provider)

Works with: @molecule/api-templating

Reference

Auto-generated, AI-first package reference for the molecule.dev ecosystem. It is written to be read by coding agents as much as by people, and is generated from this package's source — edit src/index.ts JSDoc, not this file.

Handlebars template provider for molecule.dev.

Implements the TemplateProvider interface using the Handlebars template engine. Supports Mustache-compatible syntax with helpers, partials, and pre-compiled templates for fast rendering.

Quick Start

import { setProvider } from '@molecule/api-templating'
import { provider } from '@molecule/api-templating-handlebars'

setProvider(provider)

Type

provider

Installation

npm install @molecule/api-templating-handlebars @molecule/api-templating handlebars

API

Interfaces

HandlebarsTemplateConfig

Configuration options for the Handlebars template provider.

interface HandlebarsTemplateConfig {
  /** Whether to HTML-escape output by default. Defaults to `true`. */
  escape?: boolean

  /**
   * Built-in helpers to register on creation.
   * Keys are helper names, values are helper functions.
   */
  helpers?: Record<string, (...args: unknown[]) => string>

  /**
   * Built-in partials to register on creation.
   * Keys are partial names, values are partial template strings.
   */
  partials?: Record<string, string>
}

Functions

createProvider(config)

Creates a Handlebars template provider.

function createProvider(config?: HandlebarsTemplateConfig): TemplateProvider
  • config — Provider configuration.

Returns: A TemplateProvider backed by Handlebars.

Constants

provider

The provider implementation with default configuration.

const provider: TemplateProvider

Core Interface

Implements @molecule/api-templating interface.

Bond Wiring

Setup function to register this provider with the core interface:

import { setProvider } from '@molecule/api-templating'
import { provider } from '@molecule/api-templating-handlebars'

export function setupTemplatingHandlebars(): void {
  setProvider(provider)
}

Injection Notes

Requirements

Peer dependencies:

  • @molecule/api-templating ^1.0.1

Runtime Dependencies

  • @molecule/api-templating
  • handlebars