pluralize Filter

Return a word or its plural form depending on the value of a number.

Parameters

Parameter Required Description
singular_word Yes string Word to return if the number’s value is not 1.
plural_word Yes string Word to return if the number’s value is 1.

Category

String Filters

Description

The pluralize filter accepts 2 parameters: a singular form of a word and a plural form of the word. It then chooses which word to return based on the number being filtered.

      0 {{ 0 | pluralize: 'word', 'words' }}
      1 {{ 1 | pluralize: 'word', 'words' }}
      2 {{ 2 | pluralize: 'word', 'words' }}
      

Output

      0 words
      1 word
      2 words