Registry / web-framework / oc-template-handlebars-compiler

oc-template-handlebars-compiler

JSON →
library6.7.0jsnpmunverified

OC-Template-Handlebars-Compiler is the compiler module for OpenComponents (OC) that handles compilation of components using the Handlebars templating engine. This package supports both the `oc-template-handlebars` and legacy `handlebars` template types. As part of the OC ecosystem (version 6.7.0), it integrates with the OC registry to compile Handlebars templates into server-rendered components. It is actively maintained by the OpenComponents team and ships TypeScript types. Key differentiator: it is specifically built for OpenComponents' component architecture, unlike standalone Handlebars compilers, and provides seamless integration with OC's server-side rendering pipeline.

npm install oc-template-handlebars-compiler
INSTALL
IMPORT
SIG · OC-TEMPLATE-HANDLE
O
oc-template-handlebars-compiler
web-frameworkjavascriptv6.7.0
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.

compile
import { compile } from 'oc-template-handlebars-compiler'
import compile from 'oc-template-handlebars-compiler'
Named export, not default. ESM and CJS both support named import.
getInfo
import { getInfo } from 'oc-template-handlebars-compiler'
const getInfo = require('oc-template-handlebars-compiler').getInfo
CommonJS require also works but ESM is preferred for tree-shaking. Named export as well.
oc-template-handlebars-compiler type
import type { CompilerOptions } from 'oc-template-handlebars-compiler'
import { CompilerOptions } from 'oc-template-handlebars-compiler'
TypeScript type import should use `import type` to avoid runtime overhead. Types are bundled since v6.0.

Demonstrates importing compile and getInfo, then compiling a simple Handlebars template with version and handlebars instance.

import { compile } from 'oc-template-handlebars-compiler'; import { getInfo } from 'oc-template-handlebars-compiler'; const template = '<div>{{message}}</div>'; const info = getInfo(); console.log('Compiler info:', info); const compiled = compile(template, { type: 'oc-template-handlebars' }, { version: '6.0.0', handlebars: require('handlebars') }); console.log('Compiled component:', compiled);
Debug
Known issues
breakingv6.0.0 dropped support for legacy `handlebars` type without explicit configuration. Use `type: 'oc-template-handlebars'` instead.
fix
Update component type to 'oc-template-handlebars' or configure legacy support via options.
affects: >=6.0.0
deprecatedThe `getInfo` export is deprecated as of v6.5.0. It may be removed in a future major version.
fix
Avoid using `getInfo`; rely on other OC APIs for version info.
affects: >=6.5.0
gotchaThe `compile` function requires a Handlebars instance to be passed in options. Omitting it will throw a runtime error.
fix
Always pass handlebars: require('handlebars') in the options object to compile().
affects: >=6.0.0
gotchaESM imports are supported but the package does not have a 'module' field in package.json; bundlers may need fallback to CommonJS.
fix
Ensure your bundler can resolve the main entry (CommonJS) or use a compatible module resolution strategy.
affects: >=6.0.0
breakingNode.js <12 is no longer supported since v6.0.0. Handlebars 4.x is required.
fix
Upgrade Node.js to >=12 and ensure handlebars >=4.0.0 is installed.
affects: >=6.0.0
Errors
Common errors & fixes
Error: Cannot find module 'handlebars'
handlebars peer dependency not installed
fix
Run 'npm install handlebars' in your project.
TypeError: compile is not a function
Default import used instead of named import
fix
Change 'import compile from ...' to 'import { compile } from ...'.
Error: No template found for type 'handlebars'
Legacy type string used without proper configuration
fix
Use type 'oc-template-handlebars' or enable legacy support by setting options.legacy = true.
Upgrade
Version history
6.7.0latest on npm
Audit
Dependencies
handlebarsrequiredruntime dependency for Handlebars compilation
oc-template-handlebarsoptionalextracts and precompiles the template
Agent activity
2 hits · last 30 days
node
2
Resources
oc-template-handlebars-compiler — npm install oc-template-handlebars-compiler · libregistry