tohuw / pluralize

A Liquid filter to make it easy to form correct plurals.

Geek Repo:Geek Repo

Github PK Tool:Github PK Tool

pluralize

A Liquid filter to make it easy to form correct plurals.

At some point, every programmer has had to display a count of objects, like “36 pages” or “1 message”. This Liquid filter makes it easier to form these plurals correctly—no more taking the lazy way out and writing {{ number }} message(s)! (Or worse, assuming that the number will be greater than one.)

Installation and usage

To use this plugin with Jekyll, copy pluralize.rb to your _plugins folder.

The sole provided function is pluralize. It can be used in one of two ways:

  • for regular plurals (where the plural is formed by appending an s):

      {{ remaining_time | pluralize: "minute" }}
    

    will output “0 minutes”, “1 minute”, “17 minutes”, etc.

  • for irregular plurals:

      {{ cul_de_sac_list.length | pluralize: "cul-de-sac", "culs-de-sac" }}
    

    will output “0 culs-de-sac”, “1 cul-de-sac”, “17 culs-de-sac”, etc.

Versioning

The version numbers of this project conform to Semantic Versioning 2.0.

  • 1.0.0 (2013-08-20): Initial release.

Contact

E-mail Benjamin Esham with questions or comments.

This project is hosted on GitHub. Please feel free to submit issues and pull requests.

License

This script is hereby released into the public domain. To the extent possible, the author places no restrictions upon its use, modification, or redistribution.

About

A Liquid filter to make it easy to form correct plurals.


Languages

Language:Ruby 100.0%