Registry / web-framework / handlebars-transpiler

handlebars-transpiler

JSON →
library1.0.3jsnpmunverified

Handlebars Transpiler is a Node.js module for compiling Handlebars templates along with partials, JSON data, and custom helpers into static HTML files. Version 1.0.3 is the latest stable release; the package is actively maintained with a focus on simplicity for generating static sites from Handlebars templates. It differentiates itself from other build tools by being a lightweight, zero-config CLI and programmatic API specifically for Handlebars, with no dependency on larger frameworks like Gulp or Grunt. It supports custom output paths and partials registration. It is not suitable for dynamic rendering or runtime caching.

npm install handlebars-transpiler
INSTALL
IMPORT
SIG · HANDLEBARS-TRANSPI
H
handlebars-transpiler
web-frameworkjavascriptv1.0.3
harness data pending
Install & Compatibility
Where this runs

No compatibility data collected yet for this library.

Code
Verified usage

Verified import paths — ran on the pinned version, not inferred.

transpile
import { transpile } from 'handlebars-transpiler'
const { transpile } = require('handlebars-transpiler')
ESM default export only; named import 'transpile' is the expected API.
transpileSync
import { transpileSync } from 'handlebars-transpiler'
import transpileSync from 'handlebars-transpiler'
Named export for synchronous transpilation; do not use default import.
TranspilerOptions
import type { TranspilerOptions } from 'handlebars-transpiler'
import { TranspilerOptions } from 'handlebars-transpiler'
TypeScript type export; use 'import type' to avoid runtime inclusion.

Demonstrates transpiling a Handlebars template with data, partials, and a custom helper to a static HTML file.

import { transpile } from 'handlebars-transpiler'; const config = { template: 'template.hbs', data: 'data.json', partials: ['partials/header.hbs', 'partials/footer.hbs'], helpers: { uppercase: (str) => str.toUpperCase() }, output: 'index.html' }; transpile(config).then(() => { console.log('Static HTML generated successfully'); }).catch(err => { console.error('Transpilation failed:', err); });
handlebars-transpiler --version
Debug
Known issues
gotchaThe 'partials' option expects an array of file paths, not Handlebars partial registration strings.
fix
Provide absolute or relative paths to .hbs files; partials are automatically registered with their filename (without extension).
affects: >=1.0.0 <2.0.0
deprecatedThe 'compile' function is deprecated in favor of 'transpile'.
fix
Replace any call to 'compile' with 'transpile' using the same API.
affects: >=1.0.0
gotchaThe 'data' option only accepts a JSON file path; inline data objects are not supported.
fix
Create a separate JSON file and pass its path as the 'data' option.
affects: >=1.0.0 <2.0.0
breakingVersion 1.0.0 changed the exported API from a default function to named exports ('transpile', 'transpileSync').
fix
Update imports to use named exports: import { transpile } from 'handlebars-transpiler'.
affects: >=1.0.0
Errors
Common errors & fixes
Error: Cannot find module 'handlebars'
Handlebars is a peer dependency that must be installed separately.
fix
Run 'npm install handlebars' in your project.
TypeError: template must be a string
The 'template' option provided is not a string (e.g., object or undefined).
fix
Ensure the 'template' option is a valid file path string.
Error: ENOENT: no such file or directory, open 'data.json'
The 'data' file path is incorrect or the file does not exist.
fix
Verify the path to your JSON data file is correct relative to the working directory.
Upgrade
Version history
1.0.3latest on npm
Audit
Dependencies
handlebarsrequiredrequired Handlebars runtime for compiling and executing templates
Agent activity
6 hits · last 30 days
node
6
Resources
handlebars-transpiler — npm install handlebars-transpiler · libregistry