Ecosyste.ms: Awesome
An open API service indexing awesome lists of open source software.
https://github.com/audreyfeldroy/jinja2_pluralize
Jinja2 pluralize filters.
https://github.com/audreyfeldroy/jinja2_pluralize
Last synced: 16 days ago
JSON representation
Jinja2 pluralize filters.
- Host: GitHub
- URL: https://github.com/audreyfeldroy/jinja2_pluralize
- Owner: audreyfeldroy
- License: bsd-3-clause
- Created: 2014-04-25T16:32:57.000Z (over 10 years ago)
- Default Branch: master
- Last Pushed: 2022-12-26T20:15:00.000Z (almost 2 years ago)
- Last Synced: 2024-10-01T01:59:41.772Z (about 1 month ago)
- Language: Python
- Homepage:
- Size: 29.3 KB
- Stars: 10
- Watchers: 5
- Forks: 7
- Open Issues: 8
-
Metadata Files:
- Readme: README.rst
- Changelog: HISTORY.rst
- Contributing: CONTRIBUTING.rst
- License: LICENSE
Awesome Lists containing this project
README
===============================
Jinja2 Pluralize
===============================.. image:: https://img.shields.io/pypi/v/jinja2_pluralize.svg?style=flat
:target: https://pypi.python.org/pypi/jinja2_pluralize
.. image:: https://img.shields.io/travis/audreyr/jinja2_pluralize.svg
:target: https://travis-ci.org/audreyr/jinja2_pluralize.. image:: https://api.codacy.com/project/badge/eb497c487012455688a62383afccccb7
:target: https://www.codacy.com/app/aroy/jinja2_pluralize.. image:: https://img.shields.io/pypi/pyversions/jinja2_pluralize.svg?style=flat
.. image:: https://img.shields.io/pypi/status/jinja2_pluralize.svg?style=flat
Jinja2 pluralize filters.
* Free software: BSD license
* Documentation: http://jinja2-pluralize.readthedocs.orgFeatures
--------1. Simple pluralize filter based on inflect.py. For example, this renders as `geese`:
.. code-block:: jinja
{{ 'goose'|pluralize }}
2. Django-style pluralize filter. Works as described in the `Django docs`_. For example, this renders as `votes`:
.. code-block:: jinja
vote{{ 0|pluralize }}
.. _`Django docs`: https://docs.djangoproject.com/en/dev/ref/templates/builtins/#pluralize
Usage
-----To use it with Jinja2, update the `filters` dict on the environment like this:
.. code-block:: python
from jinja2 import Environment
from jinja2_pluralize import pluralize_djenv = Environment()
env.filters['pluralize'] = pluralize_dj
tmpl = env.from_string('vote{{ 0|pluralize }}')
assert tmpl.render() == 'votes'