hp

handlebars-pluralize

Handlebars helper for pluralizing any words in any language

Showing:

Popularity

Downloads/wk

8

GitHub Stars

2

Maintenance

Last Commit

4yrs ago

Contributors

0

Package

Dependencies

0

License

MIT

Type Definitions

Tree-Shakeable

No?

Categories

Readme

handlebars-pluralize

Handlebars helper for pluralizing any words in any language.

Installation

npm i handlebars-pluralize --save

Usage

Use pluralize helper for pluralization. There are three reserved keys for determining phrases:

  • one — 1, 21, 101 etc.
  • few — 2, 3, 4, 22, 102 etc.
  • many — 5, 6, 7, 25, 105 etc.

Also you can provide explicit rule for value. See the example below.

const hbs = require("handlebars");
const pluralize = require("handlebars-pluralize");
hbs.registerHelper("pluralize", pluralize);
const template = hbs.compile("I want {{pluralize beers one='# beer' 2='two beers' few='# beers' many='# beers'}}");

let str = template({ beers: 1 });
// "I want 1 beer"

str = template({ beers: 2 });
// "I want two beers"

str = template({ beers: 5 });
// "I want 5 beers"

Tests

npm install
npm test

Dev Dependencies

License

MIT

Contributors

Rate & Review

Great Documentation0
Easy to Use0
Performant0
Highly Customizable0
Bleeding Edge0
Responsive Maintainers0
Poor Documentation0
Hard to Use0
Slow0
Buggy0
Abandoned0
Unwelcoming Community0
100
No reviews found
Be the first to rate

Alternatives

No alternatives found

Tutorials

No tutorials found
Add a tutorial