Registry / productivity / fmtr
library2.0.0jsnpmunverified

A minimal string formatting utility that substitutes placeholders using shell-style `${propertyName}` syntax. Version 2.0.0 is the current stable release; no recent updates. It is a lightweight alternative to more feature-rich template libraries (e.g., sprintf-js, lodash.template) with no dependencies. Supports Node.js and browsers via CommonJS. Key differentiator: extreme simplicity—single function, no configuration, no tags or filters.

npm install fmtr
INSTALL
IMPORT
SIG · FMTR
F
fmtr
productivityjavascriptv2.0.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.

fmtr
const fmtr = require('fmtr')
import fmtr from 'fmtr'
Package provides a CommonJS default export; no ESM module entry point. Use require.
fmtr
import fmtr from 'fmtr'
import { fmtr } from 'fmtr'
If using with bundlers that support ESM interop, default import works; named import is incorrect.
fmtr
const { default: fmtr } = require('fmtr')
const { fmtr } = require('fmtr')
In TypeScript with esModuleInterop disabled, you may need to destructure default.

Shows basic usage: require fmtr, define an object, call fmtr with a format string and the object, log result.

const fmtr = require('fmtr'); const user = { username: 'alice', spouse: 'bob', enemy: 'eve' }; const result = fmtr('${username} is married to ${spouse} and hates ${enemy}', user); console.log(result); // alice is married to bob and hates eve
Debug
Known issues
gotchaPlaceholder syntax is strictly ${propertyName}. Single braces {} or without $ will not be replaced.
fix
Ensure placeholders use exactly ${...} with a property name matching the object key.
affects: >=0.0.0
gotchaNested property access (e.g., ${user.name}) is not supported. Only top-level properties are replaced.
fix
Flatten nested objects before passing to fmtr or use a different template library.
affects: >=0.0.0
gotchaIf a placeholder references a property that does not exist in the object, it remains as literal ${propertyName} in the output.
fix
Ensure all referenced properties exist in the object to avoid unsubstituted placeholders.
affects: >=0.0.0
Errors
Common errors & fixes
TypeError: fmtr is not a function
Using default import with ESM or incorrect destructuring in CJS.
fix
Use `const fmtr = require('fmtr')` (CJS) or `import fmtr from 'fmtr'` (ESM, if bundler supports it).
ReferenceError: fmtr is not defined
Forgot to require/import the package or misspelled the variable name.
fix
Add const fmtr = require('fmtr') at the top of the file.
Uncaught SyntaxError: Unexpected token '${'
Using template literals (backticks) instead of regular string with placeholders, or not escaping properly.
fix
Use a regular string (single or double quotes) for the format argument, not a template literal.
Upgrade
Version history
2.0.0latest on npm
Audit
Dependencies

No dependency data recorded yet.

Agent activity
30 hits · last 30 days
node
28
OpenAI (training)
1
Resources
packagefmtr
fmtr — npm install fmtr · libregistry