Registry / serialization / techhead-hogan

techhead-hogan

JSON →
library0.0.1jsnpmunverified

A fork of Twitter's Hogan.js Mustache compiler (v0.0.1), adding helpers, method call chaining, dot notation, shorthand section close tags, and piped helpers. Released as a pre-1.0 package with limited documentation and bug fixes for delimiter handling and partial context access. Differentiated from Hogan.js by extended functionality for method calls and helpers, but likely incompatible with standard Mustache specifications.

npm install techhead-hogan
INSTALL
IMPORT
SIG · TECHHEAD-HOGAN
T
techhead-hogan
serializationjavascriptv0.0.1
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.

default
import hogan from 'techhead-hogan'
const hogan = require('techhead-hogan')
ESM-only; no CommonJS support declared.
compile
const { compile } = await import('techhead-hogan'); const t = compile('{{name}}', { delimiters: '{{ }}' });
import { compile } from 'techhead-hogan'; // fails if package uses default export only
compile is a method on the default export; named import may not work depending on export structure.
render
const t = (await import('techhead-hogan')).default.compile('{{name}}'); const output = t.render({ name: 'World' });
require('techhead-hogan').compile(...).render(...); // CJS not supported
Render is a method on the compiled template object.

Compile and render a basic Mustache template, then demonstrates piped helper usage with join.

import hogan from 'techhead-hogan'; const template = 'Hello {{name}}!'; const compiled = hogan.compile(template); const output = compiled.render({ name: 'World' }); console.log(output); // Hello World! // With helpers const t2 = hogan.compile("{{ names | join }}", { fixMethodCalls: 1, enableHelpers: 1 }); const r2 = t2.render({ names: ['a', 'b'], join: function(arr) { return arr.join(', '); } }); console.log(r2); // a, b
Debug
Known issues
gotchaHelpers require enableHelpers:1 and fixMethodCalls:1 options; otherwise they are ignored.
fix
Pass { enableHelpers: 1, fixMethodCalls: 1 } to compile().
affects: >=0.0.1
gotchaShorthand close tags (like {/}) depend on delimiter option { delimiters: '{ }' } and may not work with default delimiters.
fix
When using shorthand close tags, specify custom delimiters, e.g., { delimiters: '{{ }}' } or '{ }'.
affects: >=0.0.1
gotchaMethod call chaining via dot notation only works when fixMethodCalls option is enabled.
fix
Add fixMethodCalls:1 to compile options.
affects: >=0.0.1
breakingThis fork may break compatibility with standard Mustache implementations due to added features.
fix
Test templates against standard Mustache spec; avoid using new features if cross-compatibility is required.
affects: >=0.0.1
Errors
Common errors & fixes
TypeError: hogan.compile is not a function
Default import used but package emits a default export object.
fix
Use correct import: import hogan from 'techhead-hogan'; then hogan.compile().
ReferenceError: require is not defined
Attempting CommonJS require in an ESM context.
fix
Use import statement or dynamic import: const hogan = await import('techhead-hogan').then(m => m.default);
Error: Piped helper 'join' not found
Helpers not enabled; enableHelpers option missing.
fix
Compile with { enableHelpers: 1 }.
Upgrade
Version history
0.0.1latest on npm
Audit
Dependencies

No dependency data recorded yet.

Agent activity
13 hits · last 30 days
node
12
OpenAI (training)
1
Resources
techhead-hogan — npm install techhead-hogan · libregistry