Skip to main content

jinja2_humanize_extension

Status (master branch)

GitHub CI Maintenance

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:

  • 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 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!)

logo

Metadata

Release files for jinja2-humanize-extension 0.4.1

For a detailed explanation of source distributions (sdists) and built distributions (wheels), please see the package formats documentation.

Source distribution (sdist)

Source distribution for jinja2-humanize-extension 0.4.1
File Size Uploaded Provenance Actions
jinja2_humanize_extension-0.4.1.tar.gz 5.2 kB Without provenance Details for jinja2_humanize_extension-0.4.1.tar.gz

Built distribution (wheel)

Table of built distributions (wheels) for jinja2-humanize-extension 0.4.1
File Interpreter ABI Platform Actions
jinja2_humanize_extension-0.4.1-py3-none-any.whl Python 3 none any Details for jinja2_humanize_extension-0.4.1-py3-none-any.whl

Total release size: 10.1 kB

Release files / jinja2_humanize_extension-0.4.1.tar.gz

Download URL jinja2_humanize_extension-0.4.1.tar.gz
Size 5.2 kB
Tags Source
SHA-256 checksum
How to use checksums
241c191ac8087d3c187042dd471c3ecefb40aaed99318c4070f9b57ddefbc022
BLAKE2b-256 checksum
How to use checksums
bb2d0a3d60a8ecb88bc712206a45ffb69cf05c087e92101cb1692efee0345a32
Upload date
Uploaded using Trusted Publishing?
What is trusted publishing?
No
Uploaded via twine/7.0.0 CPython/3.15.2

Release files / jinja2_humanize_extension-0.4.1-py3-none-any.whl

Download URL jinja2_humanize_extension-0.4.1-py3-none-any.whl
Size 4.9 kB
Tags Python 3
SHA-256 checksum
How to use checksums
3bb7bd9869626028183ac086e4bf38b5709d99b01997c204f3bad101aa226d95
BLAKE2b-256 checksum
How to use checksums
de4868b2c0f3c349040fca7afc3d87bfce19e6f782afd40b4f99c80736de55fb
Upload date
Uploaded using Trusted Publishing?
What is trusted publishing?
No
Uploaded via twine/7.0.0 CPython/3.15.2

Security for jinja2-humanize-extension 0.4.1

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.

Anthropic, PBC Visionary sponsor Bloomberg Visionary sponsor Hudson River Trading Visionary sponsor Meta Visionary sponsor NVIDIA Visionary sponsor Microsoft Sustainability sponsor Depot Continuous Integration AWS Cloud computing and Security Sponsor Datadog Monitoring Fastly CDN Google Download Analytics Sentry Error logging StatusPage Status page