Essential Handlebars helpers in TypeScript. A modernized collection of 8 core helper categories with TypeScript support and ESM compatibility.
- ✅ TypeScript Native - Written in TypeScript with full type support
- ✅ ESM & CommonJS - Supports both module systems
- ✅ Security First - No security vulnerabilities, minimal dependencies
- ✅ Performance Focused - Native implementations instead of heavy dependencies
- ✅ Well Tested - 315+ comprehensive tests covering all helpers
- ✅ Modern Tooling - Built with pnpm, compiled with TypeScript
Install with npm:
npm install handlebars-helpers-v2
Install with pnpm:
pnpm add handlebars-helpers-v2
Install with yarn:
yarn add handlebars-helpers-v2
import { array, string, math } from 'handlebars-helpers-v2';
import Handlebars from 'handlebars';
// Register specific helper categories
Object.keys(array).forEach(name => {
Handlebars.registerHelper(name, array[name]);
});
Object.keys(string).forEach(name => {
Handlebars.registerHelper(name, string[name]);
});
import handlebarsHelpers from 'handlebars-helpers-v2';
import Handlebars from 'handlebars';
// Register all helpers automatically
handlebarsHelpers({ handlebars: Handlebars });
// Or get specific collections
const arrayHelpers = handlebarsHelpers(['array']);
const stringAndMathHelpers = handlebarsHelpers(['string', 'math']);
// Or get all helpers as an object
const allHelpers = handlebarsHelpers();
import handlebarsHelpers from 'handlebars-helpers-v2';
import Handlebars from 'handlebars';
// Auto-register specific category
handlebarsHelpers.array({ handlebars: Handlebars });
handlebarsHelpers.string({ handlebars: Handlebars });
// Or just get the helpers without registering
const arrayHelpers = handlebarsHelpers.array();
const stringHelpers = handlebarsHelpers.string();
const { array, string, math } = require('handlebars-helpers-v2');
const Handlebars = require('handlebars');
// Register specific helper categories
Object.keys(array).forEach(name => {
Handlebars.registerHelper(name, array[name]);
});
Object.keys(string).forEach(name => {
Handlebars.registerHelper(name, string[name]);
});
const handlebarsHelpers = require('handlebars-helpers-v2').default;
const Handlebars = require('handlebars');
// Register all helpers automatically
handlebarsHelpers({ handlebars: Handlebars });
// Or use getter functions
handlebarsHelpers.array({ handlebars: Handlebars });
handlebarsHelpers.string({ handlebars: Handlebars });
import { array, string, math } from 'handlebars-helpers-v2';
import handlebarsHelpers from 'handlebars-helpers-v2';
import * as Handlebars from 'handlebars';
// Import named exports with full type support
Object.entries(array).forEach(([name, helper]) => {
Handlebars.registerHelper(name, helper);
});
// Or use default export with auto-registration
handlebarsHelpers({ handlebars: Handlebars });
// Or use getter functions with types
const arrayHelpers = handlebarsHelpers.array();
const stringHelpers = handlebarsHelpers.string();
This package includes 8 essential helper categories:
Category | Helpers | Description |
---|---|---|
array | 25+ | Array manipulation and iteration |
collection | 2+ | Object and collection utilities |
comparison | 15+ | Logical comparisons and conditionals |
date | 5+ | Date formatting and manipulation |
math | 10+ | Mathematical operations |
number | 10+ | Number formatting and utilities |
string | 30+ | String manipulation and formatting |
url | 5+ | URL parsing and manipulation |
Each category is exported as a separate object:
import {
array, // Array helpers
collection, // Collection helpers
comparison, // Comparison helpers
date, // Date helpers
math, // Math helpers
number, // Number helpers
string, // String helpers
url // URL helpers
} from 'handlebars-helpers-v2';
You can also import individual helpers:
// Array helpers
const { first, last, join, sort } = array;
// String helpers
const { capitalize, truncate, replace } = string;
// Math helpers
const { add, subtract, multiply, divide } = math;
- Fork the repository
- Create a feature branch:
git checkout -b my-new-feature
- Make your changes and add tests
- Run tests:
pnpm test
- Build:
pnpm build
- Commit:
git commit -am 'Add some feature'
- Push:
git push origin my-new-feature
- Submit a pull request
# Install dependencies
pnpm install
# Run tests
pnpm test
# Build TypeScript
pnpm build
# Run linting
pnpm lint
# Run type checking
pnpm typecheck
- Complete TypeScript rewrite
- Modern ESM/CommonJS dual package
- Reduced from 130+ to 80+ essential helpers
- Zero security vulnerabilities
- Native implementations replace heavy dependencies
- 315+ comprehensive tests
- Full type safety
Released under the MIT License.
This project is a TypeScript rewrite and modernization of the original handlebars-helpers by Jon Schlinkert and contributors. The original project provided the foundation and inspiration for this modern implementation.
Original Repository: https://github.com/helpers/handlebars-helpers
Original Author: Jon Schlinkert
License: MIT (maintained)
- handlebars - The semantic template language
- template-helpers - Generic template helpers
- handlebars-helpers - Original handlebars-helpers project
Modernized with ❤️ for the TypeScript era