a jinja2 extension to access to system environment variables
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.0.4.tar.gz
Algorithm | Hash digest | |
---|---|---|
SHA256 | 66a6824f8eecc42ecf57fb281f6ae9370b480b6e77c1b4ef4ef06799eb0b0f67 |
|
MD5 | 087694897132bf498402f151710b755f |
|
BLAKE2b-256 | 162a1b9c1ab4ba5d5ab33b6788783dc67e3b9f9e82bc2bb02fb95f7ffc795d63 |
Close
Hashes for jinja2_humanize_extension-0.0.4-py3-none-any.whl
Algorithm | Hash digest | |
---|---|---|
SHA256 | 31da89a09ad156108a9888f8e3b0b6af98c24fe77c4ba9012df3f49428c68347 |
|
MD5 | 0ec2dce6734b804cbb4a290cce23eb18 |
|
BLAKE2b-256 | 21b68b3586a14f3945756c8d701b15a7096c7581bd4770a9f1b09236acde5447 |