Field Helpers - Inflections 


  • inflect 
  • ordinalize 
  • pluralizer


{{inflect}}

Returns the plural or singular form of a word based on a count.

Parameters:

  • singular string - The singular form of the word. (Required)
  • plural string - The plural form of the word. (Required)
  • include boolean - whether or not to include the count before the word. (Optional)

Data:

enemies = 0
friends = 1

Template:

{{inflect enemies "enemy" "enemies"}}
{{inflect friends "friend" "friends" true}}

Renders to:

enemies
1 friend

{{ {{ordinalize}}

Turns a number into an ordinal string. Taken from the templating library Walrus by Jeremy Ruppel.

Parameters: none

Template:

{{ordinalize 3}}
{{ordinalize 1}}
{{ordinalize 22}}

Renders to:

3rd
1st
22nd

{{ {{pluralizer}}

Returns the plural or singular form of a word based on a count.

Parameters:

  • singular string - The singular form of the word. (Required)
  • plural string - The plural form of the word. (Required)
  • value integer - show singular if one or plural otherwise