This page last changed on Oct 18, 2011 by jed.wheeler@involver.com.
Overview
This filter accepts a number, and two words - one for singular, one for plural and returns the singular word if input equals 1, otherwise the plural.
Attributes
name |
type |
required |
description |
var |
string |
false |
This is a parameter for this tag. |
Examples
The filter will attempt to guess the plural version of the passed word
{{ 5 | pluralize: 'dog' }} # => 5 dogs
{{ 1 | pluralize: 'dog' }} # => 1 dog
{{ 0 | pluralize: 'dog' }} # => 0 dogs
Alternatively, you can explicitly define your plural word
{{ 5 | pluralize: 'dog', 'canines' }} # => 5 canines
{{ 1 | pluralize: 'dog', 'canines' }} # => 1 dog
{{ 0 | pluralize: 'dog', 'canines' }} # => 0 canines
And, of course, you can apply the filter on a liquid variable:
You have {{ cart.item_count | pluralize: 'item', 'items' }} in your shopping cart.
Related Topics
|