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:
naturalsize
abs_timedelta
date_and_delta
naturaldate
naturalday
naturaldelta
naturaltime
precisedelta
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
Close
Hashes for jinja2_humanize_extension-0.1.0.tar.gz
Algorithm | Hash digest | |
---|---|---|
SHA256 | 75637507baac9d102903032e49c8e325f3917036fa7e899ab46d1eecb87ed89d |
|
MD5 | d6dca639516f36531465b9252b48019f |
|
BLAKE2b-256 | 3e85012fd77ed30922aca82fc73e4fa64a5af5591a9ca00f9c30e83874846187 |
Close
Hashes for jinja2_humanize_extension-0.1.0-py3-none-any.whl
Algorithm | Hash digest | |
---|---|---|
SHA256 | 67dcac5886869e71671588f62f26e37f35843e2c0fce30ef4e943c76f04c38db |
|
MD5 | 3d9a183831b62348234a2b2d4a5adb77 |
|
BLAKE2b-256 | 878783b8e864f9b8de41f5ed333e91dae5c44a942413454e2765ef989457f0f9 |