Huge News!Announcing our $40M Series B led by Abstract Ventures.Learn More
Socket
Sign inDemoInstall
Socket

handlebars-pluralize

Package Overview
Dependencies
Maintainers
1
Versions
3
Alerts
File Explorer

Advanced tools

Socket logo

Install Socket

Detect and block malicious and high-risk dependencies

Install

handlebars-pluralize

Handlebars helper for pluralizing any words in any language

  • 1.0.2
  • latest
  • Source
  • npm
  • Socket score

Version published
Weekly downloads
4
Maintainers
1
Weekly downloads
 
Created
Source

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

  • handlebars
  • mocha

License

MIT

Contributors

Keywords

FAQs

Package last updated on 14 Nov 2017

Did you know?

Socket

Socket for GitHub automatically highlights issues in each pull request and monitors the health of all your open source dependencies. Discover the contents of your packages and block harmful activity before you install or update your dependencies.

Install

Related posts

SocketSocket SOC 2 Logo

Product

  • Package Alerts
  • Integrations
  • Docs
  • Pricing
  • FAQ
  • Roadmap
  • Changelog

Packages

npm

Stay in touch

Get open source security insights delivered straight into your inbox.


  • Terms
  • Privacy
  • Security

Made with ⚡️ by Socket Inc