a jinja2 extension to use humanize library inside jinja2 templates
Project description
What is it ?
This is a jinja2 extension to use humanize library inside jinja2 templates.
Syntax
The generic syntax is {% raw %}{{ 'VALUE'|humanize_{humanize_fn}([humanize_fn_args]) }}{% endraw %}.
Following humanize functions are currently mapped:
naturalsizeabs_timedeltadate_and_deltanaturaldatenaturaldaynaturaldeltanaturaltimeprecisedelta
See humanize documentation for argument details.
To take a more real example, let's take the naturalsize() function. To use it inside a jinja2 template with this extension, you have to use:
The file size is: {% raw %}{{ 30000000|humanize_naturalsize(binary=False, gnu=True) }}{% endraw %}
Full example
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 : {% raw %}{{ 30000000|humanize_naturalsize() }}{% endraw %}")
result = template.render()
# [...]
Project details
Download files
Download the file for your platform. If you're not sure which to choose, learn more about installing packages.
Source Distribution
Built Distribution
Filter files by name, interpreter, ABI, and platform.
If you're not sure about the file name format, learn more about wheel file names.
Copy a direct link to the current filters
File details
Details for the file jinja2_humanize_extension-0.1.0.tar.gz.
File metadata
- Download URL: jinja2_humanize_extension-0.1.0.tar.gz
- Upload date:
- Size: 3.2 kB
- Tags: Source
- Uploaded using Trusted Publishing? No
- Uploaded via: twine/3.3.0 pkginfo/1.7.0 requests/2.25.1 setuptools/49.2.1 requests-toolbelt/0.9.1 tqdm/4.56.2 CPython/3.9.1
File hashes
| Algorithm | Hash digest | |
|---|---|---|
| SHA256 |
75637507baac9d102903032e49c8e325f3917036fa7e899ab46d1eecb87ed89d
|
|
| MD5 |
d6dca639516f36531465b9252b48019f
|
|
| BLAKE2b-256 |
3e85012fd77ed30922aca82fc73e4fa64a5af5591a9ca00f9c30e83874846187
|
File details
Details for the file jinja2_humanize_extension-0.1.0-py3-none-any.whl.
File metadata
- Download URL: jinja2_humanize_extension-0.1.0-py3-none-any.whl
- Upload date:
- Size: 3.7 kB
- Tags: Python 3
- Uploaded using Trusted Publishing? No
- Uploaded via: twine/3.3.0 pkginfo/1.7.0 requests/2.25.1 setuptools/49.2.1 requests-toolbelt/0.9.1 tqdm/4.56.2 CPython/3.9.1
File hashes
| Algorithm | Hash digest | |
|---|---|---|
| SHA256 |
67dcac5886869e71671588f62f26e37f35843e2c0fce30ef4e943c76f04c38db
|
|
| MD5 |
3d9a183831b62348234a2b2d4a5adb77
|
|
| BLAKE2b-256 |
878783b8e864f9b8de41f5ed333e91dae5c44a942413454e2765ef989457f0f9
|