jinja2_humanize_extension
Status (master branch)
What is it ?
This is a jinja2 extension to use humanize library inside jinja2 templates.
Syntax
The generic syntax is {{ 'VALUE'|humanize_{humanize_fn}([humanize_fn_args]) }}.
Following humanize functions are currently mapped:
naturalsizeabs_timedelta(deprecated with humanize >= 4.0, we keep it for compatibility)date_and_delta(deprecated with humanize >= 4.0, we keep it for compatibility)naturaldatenaturaldaynaturaldeltanaturaltimeprecisedeltaordinalintcommaintwordapnumberfractionalscientificclampmetricactivatedeactivatethousands_separatordecimal_separator
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: {{ 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
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 file.
Code of Conduct
See 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!)
Metadata
Release files for jinja2-humanize-extension 0.4.0
For a detailed explanation of source distributions (sdists) and built distributions (wheels), please see the package formats documentation.
Source distribution (sdist)
| File | Size | Uploaded | Provenance | |
|---|---|---|---|---|
| jinja2_humanize_extension-0.4.0.tar.gz | 4.7 kB | Without provenance | Details |
Built distribution (wheel)
| File | Interpreter | ABI | Platform | Reset |
|---|---|---|---|---|
| jinja2_humanize_extension-0.4.0-py3-none-any.whl | Python 3 | none | any | Details |
Total release size: 9.5 kB
Release files / jinja2_humanize_extension-0.4.0.tar.gz
| Download URL | jinja2_humanize_extension-0.4.0.tar.gz |
|---|---|
| Size | 4.7 kB |
| Tags | Source |
|
SHA-256 checksum How to use checksums |
e7d69b1c20f32815bbec722330ee8af14b1287bb1c2b0afa590dbf031cadeaa0
|
|
BLAKE2b-256 checksum How to use checksums |
74770bba383819dd4e67566487c11c49479ced87e77c3285d8e7f7a3401cf882
|
| Upload date | |
|
Uploaded using Trusted Publishing? What is trusted publishing? |
No |
| Uploaded via |
twine/4.0.2 CPython/3.11.4
|
Release files / jinja2_humanize_extension-0.4.0-py3-none-any.whl
| Download URL | jinja2_humanize_extension-0.4.0-py3-none-any.whl |
|---|---|
| Size | 4.8 kB |
| Tags | Python 3 |
|
SHA-256 checksum How to use checksums |
b6326e2da0f7d425338bebf58848e830421defbce785f12ae812e65128518156
|
|
BLAKE2b-256 checksum How to use checksums |
26b408c9d297edd5e1182506edecccbb88a92e1122a057953068cadac420ca5d
|
| Upload date | |
|
Uploaded using Trusted Publishing? What is trusted publishing? |
No |
| Uploaded via |
twine/4.0.2 CPython/3.11.4
|
Security for jinja2-humanize-extension 0.4.0
Provenance
Provenance describes where a file came from. On PyPI, provenance is shared via attestations, which provide a verifiable record of the build or publishing details. View details, limitations and caveats.
No provenance found
None of the files in this release were uploaded with provenance metadata.
A note on package security
PyPI is a repository for distributing packages, not a service for auditing them. While third-party security researchers and our staff do their best to detect and remove malicious packages, PyPI cannot guarantee the quality, security or suitability of any given package.
To learn more about protecting yourself from malicious actors, visit our package security documentation.