Skip to main content

HMLR Frontend Jinja Macros

PyPI version Static Badge Python package

This repository provides a complete set of Jinja macros that are kept up-to-date and 100% compliant with the original HMLR Frontend Nunjucks macros. Porting is intentionally manual rather than automated to make updates simpler than maintaining an automated conversion routine.

Compatibility

The following table shows the version of HMLR Frontend Jinja that you should use for your targeted version of HMLR Frontend:

HMLR Frontend Jinja Version Target Frontend Version
4.0.0 GOV.UK Frontend 6.4.0
3.0.0 GOV.UK Frontend 5.13.0
2.0.0 HMLR Frontend 2.0.0
1.1.0 HMLR Frontend 1.4.0
1.0.0 HMLR Frontend 1.1.0
0.2.0 HMLR Frontend 1.0.0-rc1

Any other versions of HMLR Frontend not shown above may still be compatible, but have not been specifically tested and verified.

How to use

After running pip install hmlr-frontend-jinja, ensure that you tell Jinja where to load the templates from using the PackageLoader as follows:

from flask import Flask
from jinja2 import ChoiceLoader, PackageLoader, PrefixLoader

app = Flask(__name__)

app.jinja_loader = ChoiceLoader(
    [
        PackageLoader("server"),
        PrefixLoader(
            {
                "govuk_frontend_jinja": PackageLoader("govuk_frontend_jinja"),
                "govuk_frontend_wtf": PackageLoader("govuk_frontend_wtf"),
                "hmlr_frontend_jinja": PackageLoader("hmlr_frontend_jinja"),
            }
        ),
    ]
)

Calling a Macro in your template

To use a component in your project templates you must import and call the component macro and pass the relevant options, for example:

{%- from 'hmlr_frontend_jinja/components/header/macro.html' import hmlrHeader -%}

{{ hmlrHeader({}) }}

The options available to each component macro can be found in the original HMLR Design System Components documentation. Since this project is a like-for-like port, the only difference between the Nunjucks examples and their Jinja equivalents is having to quote key names, e.g. 'text' instead of text.

Versioning

We use SemVer for versioning. For the versions available, see the tags on this repository.

How to contribute

We welcome contribution from the community. If you want to contribute to this project, please review the code of conduct and contribution guidelines.

Contributors

Metadata

Release files for hmlr-frontend-jinja 4.0.0

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

Source distribution (sdist)

Source distribution for hmlr-frontend-jinja 4.0.0
File Size Uploaded
hmlr_frontend_jinja-4.0.0.tar.gz 11.2 kB Details

Built distribution (wheel)

Table of built distributions (wheels) for hmlr-frontend-jinja 4.0.0
File Interpreter ABI Platform
hmlr_frontend_jinja-4.0.0-py3-none-any.whl Python 3 none any Details

Total release size: 21.5 kB

Release files / hmlr_frontend_jinja-4.0.0.tar.gz

Download URL hmlr_frontend_jinja-4.0.0.tar.gz
Size 11.2 kB
Tags Source
SHA-256 checksum
How to use checksums
6309630e2be662829bd1ffa2f8722248f9f63247259fc237f9cc966a8c9c325b
BLAKE2b-256 checksum
How to use checksums
b904ab0157153f1acf7a3b6d7c3e78ea6893d5d0f63d4878c5b962a06c0ec314
Upload date
Uploaded using Trusted Publishing?
What is trusted publishing?
No
Uploaded via twine/6.2.0 CPython/3.9.25

Release files / hmlr_frontend_jinja-4.0.0-py3-none-any.whl

Download URL hmlr_frontend_jinja-4.0.0-py3-none-any.whl
Size 10.3 kB
Tags Python 3
SHA-256 checksum
How to use checksums
b3bfcf38c3e4030c18f3c9c33d744682d13d8ff4e2cb83bd72463ac45a388a45
BLAKE2b-256 checksum
How to use checksums
ebf0afaebf8ea4aacbd3ac1886835056c7c5c207065fccfe7b2b627f1b253092
Upload date
Uploaded using Trusted Publishing?
What is trusted publishing?
No
Uploaded via twine/6.2.0 CPython/3.9.25
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