
Security News
Next.js Patches Critical Middleware Vulnerability (CVE-2025-29927)
Next.js has patched a critical vulnerability (CVE-2025-29927) that allowed attackers to bypass middleware-based authorization checks in self-hosted apps.
jinja2-humanize-extension
Advanced tools
a jinja2 extension to use humanize library inside jinja2 templates
Status (master branch)
This is a jinja2 extension to use humanize library inside jinja2 templates.
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.
pip install jinja2-humanize-extension
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
See CONTRIBUTING.md file.
See CODE_OF_CONDUCT.md file.
(If you are officially paid to work on MetWork Framework, please contact us to add your company logo here!)
FAQs
a jinja2 extension to use humanize library inside jinja2 templates
We found that jinja2-humanize-extension demonstrated a healthy version release cadence and project activity because the last version was released less than a year ago. It has 2 open source maintainers collaborating on the project.
Did you know?
Socket for GitHub automatically highlights issues in each pull request and monitors the health of all your open source dependencies. Discover the contents of your packages and block harmful activity before you install or update your dependencies.
Security News
Next.js has patched a critical vulnerability (CVE-2025-29927) that allowed attackers to bypass middleware-based authorization checks in self-hosted apps.
Security News
A survey of 500 cybersecurity pros reveals high pay isn't enough—lack of growth and flexibility is driving attrition and risking organizational security.
Product
Socket, the leader in open source security, is now available on Google Cloud Marketplace for simplified procurement and enhanced protection against supply chain attacks.