Skip to main content
2025 Python Packaging Survey is now live!  Take the survey now

Jinja2 pluralize filters.

Project description

https://badge.fury.io/py/jinja2_pluralize.png https://travis-ci.org/audreyr/jinja2_pluralize.png?branch=master

Jinja2 pluralize filters.

Features

  1. Simple pluralize filter based on inflect.py. For example, this renders as geese:

{{ 'goose'|pluralize }}
  1. Django-style pluralize filter. Works as described in the Django docs. For example, this renders as votes:

vote{{ 0|pluralize }}

Usage

To use it with Jinja2, update the filters dict on the environment like this:

from jinja2 import Environment
from jinja2_pluralize import pluralize_dj

env = Environment()
env.filters['pluralize'] = pluralize_dj
tmpl = env.from_string('vote{{ 0|pluralize }}')
assert tmpl.render() == 'votes'

History

0.2.1 (2014-07-09)

  • Remove the shebang from __init__.py (#2), thanks to @dashea.

0.2.0 (2014-07-02)

  • Package works as per the README.

0.1.0 (2014-04-25)

  • First release on PyPI.

Supported by

AWS Cloud computing and Security Sponsor Datadog Monitoring Fastly CDN Google Download Analytics Pingdom Monitoring Sentry Error logging StatusPage Status page