# jinja2_humanize_extension
[//]: # (automatically generated from https://github.com/metwork-framework/github_organization_management/blob/master/common_files/README.md)
**Status (master branch)**
[![GitHub CI](https://github.com/metwork-framework/jinja2_humanize_extension/workflows/CI/badge.svg?branch=master)](https://github.com/metwork-framework/jinja2_humanize_extension/actions?query=workflow%3ACI+branch%3Amaster)
[![Maintenance](https://raw.githubusercontent.com/metwork-framework/resources/master/badges/maintained.svg)](https://github.com/metwork-framework/resources/blob/master/badges/maintained.svg)
## What is it ?
This is a [jinja2](http://jinja.pocoo.org/) extension to use [humanize](https://python-humanize.readthedocs.io/) library inside jinja2 templates.
## Syntax
The generic syntax is `{{ 'VALUE'|humanize_{humanize_fn}([humanize_fn_args]) }}`.
Following [humanize](https://python-humanize.readthedocs.io/) functions are currently mapped:
- `naturalsize`
- `abs_timedelta` (deprecated with humanize >= 4.0, we keep it for compatibility)
- `date_and_delta` (deprecated with humanize >= 4.0, we keep it for compatibility)
- `naturaldate`
- `naturalday`
- `naturaldelta`
- `naturaltime`
- `precisedelta`
- `ordinal`
- `intcomma`
- `intword`
- `apnumber`
- `fractional`
- `scientific`
- `clamp`
- `metric`
- `activate`
- `deactivate`
- `thousands_separator`
- `decimal_separator`
See [humanize](https://python-humanize.readthedocs.io/) documentation for argument details.
To take a more real example, let's take the [naturalsize()](https://python-humanize.readthedocs.io/en/latest/filesize/) function. To use it inside a [jinja2](http://jinja.pocoo.org/) template with this extension, you
have to use:
```
The file size is: {{ 30000000|humanize_naturalsize(binary=False, gnu=True) }}
```
result content will be : `The file size is : 30.0 MB`
You can use the same logic with all supported functions. If you need other functions, feel
free to open a PullRequest.
## Installation
```
pip install jinja2-humanize-extension
```
## Full example
```python
from jinja2 import Template, Environment
# We load the extension in a jinja2 Environment
env = Environment(extensions=["jinja2_humanize_extension.HumanizeExtension"])
template = env.from_string("The file size is : {{ 30000000|humanize_naturalsize() }}")
result = template.render()
# [...]
```
result content will be : `The file size is : 30.0 MB`
## Contributing guide
See [CONTRIBUTING.md](CONTRIBUTING.md) file.
## Code of Conduct
See [CODE_OF_CONDUCT.md](CODE_OF_CONDUCT.md) file.
## Sponsors
*(If you are officially paid to work on MetWork Framework, please contact us to add your company logo here!)*
[![logo](https://raw.githubusercontent.com/metwork-framework/resources/master/sponsors/meteofrance-small.jpeg)](http://www.meteofrance.com)
Raw data
{
"_id": null,
"home_page": "https://github.com/metwork-framework/jinja2_humanize_extension",
"name": "jinja2-humanize-extension",
"maintainer": "",
"docs_url": null,
"requires_python": ">=3.0",
"maintainer_email": "",
"keywords": "jinja2 extension",
"author": "Fabien MARTY, Jean-Baptiste VESLIN",
"author_email": "fabien.marty@gmail.com, jbaptiste31@free.fr",
"download_url": "https://files.pythonhosted.org/packages/74/77/0bba383819dd4e67566487c11c49479ced87e77c3285d8e7f7a3401cf882/jinja2_humanize_extension-0.4.0.tar.gz",
"platform": null,
"description": "# jinja2_humanize_extension\n\n[//]: # (automatically generated from https://github.com/metwork-framework/github_organization_management/blob/master/common_files/README.md)\n\n**Status (master branch)**\n\n\n\n[![GitHub CI](https://github.com/metwork-framework/jinja2_humanize_extension/workflows/CI/badge.svg?branch=master)](https://github.com/metwork-framework/jinja2_humanize_extension/actions?query=workflow%3ACI+branch%3Amaster)\n[![Maintenance](https://raw.githubusercontent.com/metwork-framework/resources/master/badges/maintained.svg)](https://github.com/metwork-framework/resources/blob/master/badges/maintained.svg)\n\n\n\n\n## What is it ?\n\nThis is a [jinja2](http://jinja.pocoo.org/) extension to use [humanize](https://python-humanize.readthedocs.io/) library inside jinja2 templates.\n\n## Syntax\n\nThe generic syntax is `{{ 'VALUE'|humanize_{humanize_fn}([humanize_fn_args]) }}`.\n\nFollowing [humanize](https://python-humanize.readthedocs.io/) functions are currently mapped:\n\n- `naturalsize`\n- `abs_timedelta` (deprecated with humanize >= 4.0, we keep it for compatibility)\n- `date_and_delta` (deprecated with humanize >= 4.0, we keep it for compatibility)\n- `naturaldate`\n- `naturalday`\n- `naturaldelta`\n- `naturaltime`\n- `precisedelta`\n- `ordinal`\n- `intcomma`\n- `intword`\n- `apnumber`\n- `fractional`\n- `scientific`\n- `clamp`\n- `metric`\n- `activate`\n- `deactivate`\n- `thousands_separator`\n- `decimal_separator`\n\nSee [humanize](https://python-humanize.readthedocs.io/) documentation for argument details.\n\nTo take a more real example, let's take the [naturalsize()](https://python-humanize.readthedocs.io/en/latest/filesize/) function. To use it inside a [jinja2](http://jinja.pocoo.org/) template with this extension, you\nhave to use:\n\n```\n\nThe file size is: {{ 30000000|humanize_naturalsize(binary=False, gnu=True) }}\n\n```\n\nresult content will be : `The file size is : 30.0 MB`\n\nYou can use the same logic with all supported functions. If you need other functions, feel\nfree to open a PullRequest.\n\n## Installation\n\n```\npip install jinja2-humanize-extension\n```\n\n## Full example\n\n```python\n\nfrom jinja2 import Template, Environment\n\n# We load the extension in a jinja2 Environment\nenv = Environment(extensions=[\"jinja2_humanize_extension.HumanizeExtension\"])\n\ntemplate = env.from_string(\"The file size is : {{ 30000000|humanize_naturalsize() }}\")\nresult = template.render()\n\n# [...]\n```\n\nresult content will be : `The file size is : 30.0 MB`\n\n\n\n\n\n\n## Contributing guide\n\nSee [CONTRIBUTING.md](CONTRIBUTING.md) file.\n\n\n\n## Code of Conduct\n\nSee [CODE_OF_CONDUCT.md](CODE_OF_CONDUCT.md) file.\n\n\n\n## Sponsors\n\n*(If you are officially paid to work on MetWork Framework, please contact us to add your company logo here!)*\n\n[![logo](https://raw.githubusercontent.com/metwork-framework/resources/master/sponsors/meteofrance-small.jpeg)](http://www.meteofrance.com)\n",
"bugtrack_url": null,
"license": "BSD",
"summary": "a jinja2 extension to use humanize library inside jinja2 templates",
"version": "0.4.0",
"project_urls": {
"Homepage": "https://github.com/metwork-framework/jinja2_humanize_extension"
},
"split_keywords": [
"jinja2",
"extension"
],
"urls": [
{
"comment_text": "",
"digests": {
"blake2b_256": "26b408c9d297edd5e1182506edecccbb88a92e1122a057953068cadac420ca5d",
"md5": "7f5cf59c0d32a97b8f63ee5b4ee271c9",
"sha256": "b6326e2da0f7d425338bebf58848e830421defbce785f12ae812e65128518156"
},
"downloads": -1,
"filename": "jinja2_humanize_extension-0.4.0-py3-none-any.whl",
"has_sig": false,
"md5_digest": "7f5cf59c0d32a97b8f63ee5b4ee271c9",
"packagetype": "bdist_wheel",
"python_version": "py3",
"requires_python": ">=3.0",
"size": 4769,
"upload_time": "2023-09-01T12:52:41",
"upload_time_iso_8601": "2023-09-01T12:52:41.098526Z",
"url": "https://files.pythonhosted.org/packages/26/b4/08c9d297edd5e1182506edecccbb88a92e1122a057953068cadac420ca5d/jinja2_humanize_extension-0.4.0-py3-none-any.whl",
"yanked": false,
"yanked_reason": null
},
{
"comment_text": "",
"digests": {
"blake2b_256": "74770bba383819dd4e67566487c11c49479ced87e77c3285d8e7f7a3401cf882",
"md5": "183beafb49887ad7ba632707407870d7",
"sha256": "e7d69b1c20f32815bbec722330ee8af14b1287bb1c2b0afa590dbf031cadeaa0"
},
"downloads": -1,
"filename": "jinja2_humanize_extension-0.4.0.tar.gz",
"has_sig": false,
"md5_digest": "183beafb49887ad7ba632707407870d7",
"packagetype": "sdist",
"python_version": "source",
"requires_python": ">=3.0",
"size": 4746,
"upload_time": "2023-09-01T12:52:42",
"upload_time_iso_8601": "2023-09-01T12:52:42.781818Z",
"url": "https://files.pythonhosted.org/packages/74/77/0bba383819dd4e67566487c11c49479ced87e77c3285d8e7f7a3401cf882/jinja2_humanize_extension-0.4.0.tar.gz",
"yanked": false,
"yanked_reason": null
}
],
"upload_time": "2023-09-01 12:52:42",
"github": true,
"gitlab": false,
"bitbucket": false,
"codeberg": false,
"github_user": "metwork-framework",
"github_project": "jinja2_humanize_extension",
"travis_ci": false,
"coveralls": false,
"github_actions": true,
"requirements": [
{
"name": "jinja2",
"specs": []
},
{
"name": "humanize",
"specs": [
[
">=",
"3.14.0"
]
]
}
],
"lcname": "jinja2-humanize-extension"
}