Registry / web-framework / spacebars-compiler

spacebars-compiler

JSON →
library1.6.0jsnpmunverified

Spacebars Compiler compiles Spacebars templates (Handlebars-based syntax used in Meteor) into JavaScript modules compatible with Node.js and browser bundlers. Currently at version 1.6.0. It provides both CLI and programmatic usage for transforming templates into renderable JS functions. Key differentiator: it targets Meteor's Spacebars dialect, not general Handlebars, and supports i18n. Release cadence appears low as the author eface2face maintains it sporadically. Use when migrating Meteor templates to standalone Node/browser apps.

npm install spacebars-compiler
INSTALL
IMPORT
SIG · SPACEBARS-COMPILER
S
spacebars-compiler
web-frameworkjavascriptv1.6.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 'spacebars-compiler'
✗ const compile = require('spacebars-compiler').compile
Default export is the compile function, but named export 'compile' is also available and preferred for ESM.
default
✓ import compile from 'spacebars-compiler'
✗ const compile = require('spacebars-compiler')
Require returns an object that includes compile, so destructuring is needed; direct call fails.
compile
✓ const { compile } = require('spacebars-compiler')
✗ const compile = require('spacebars-compiler')
For CommonJS, destructure to get the compile function, otherwise you get the namespace object.

Compile a basic Spacebars template string into a JavaScript function string.

import { compile } from 'spacebars-compiler'; const source = '{{#each items}}<li>{{name}}</li>{{/each}}'; const options = { isBody: true, useGlobalScope: false }; const output = compile(source, options); console.log(output);
spacebars-compiler --version
Debug
Known issues
gotchaThe compile function expects Spacebars-specific syntax (e.g., {{#each}}, {{#with}}), not standard Handlebars.
fix
Ensure your templates are Meteor Spacebars templates; use a different compiler for Handlebars.
affects: >=0.0.0
gotchaIf using the CLI, ensure the output file path is writable and directories exist.
fix
Check file permissions and use --dir to specify an existing directory.
affects: >=0.0.0
gotchaThe package does not ship bundled type definitions; TypeScript users need to provide their own or use @types/spacebars-compiler if available.
fix
Add declare module 'spacebars-compiler' or install community typings.
affects: >=0.0.0
Errors
Common errors & fixes
Cannot find module 'spacebars-compiler'
Package not installed or not in node_modules.
fix
Run 'npm install spacebars-compiler' and ensure it's in your dependencies.
TypeError: compile is not a function
Importing the default export incorrectly in CommonJS (require returns an object).
fix
Use const { compile } = require('spacebars-compiler');
Unexpected identifier: '...'
Template contains syntax not valid Spacebars; may be using standard Handlebars helpers.
fix
Validate template strictly against Spacebars grammar.
Upgrade
Version history
1.6.0latest on npm
Audit
Dependencies

No dependency data recorded yet.

Agent activity
4 hits · last 30 days
node
4
Resources
spacebars-compiler — npm install spacebars-compiler · libregistry