Skip to main content

HMLR Frontend Jinja Macros

Project description

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
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

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

hmlr_frontend_jinja-3.0.0.tar.gz (10.2 kB view details)

Uploaded Source

Built Distribution

If you're not sure about the file name format, learn more about wheel file names.

hmlr_frontend_jinja-3.0.0-py3-none-any.whl (9.3 kB view details)

Uploaded Python 3

File details

Details for the file hmlr_frontend_jinja-3.0.0.tar.gz.

File metadata

  • Download URL: hmlr_frontend_jinja-3.0.0.tar.gz
  • Upload date:
  • Size: 10.2 kB
  • Tags: Source
  • Uploaded using Trusted Publishing? No
  • Uploaded via: twine/6.2.0 CPython/3.9.25

File hashes

Hashes for hmlr_frontend_jinja-3.0.0.tar.gz
Algorithm Hash digest
SHA256 7b4ad867a3194337ff2e09a22ef7a3ac7eda9eff01f9e4857748f9f012cf9ffb
MD5 0274277f38a21eeef73b7c664361a960
BLAKE2b-256 871bf84c68392291e9f3711f8323f5761a2ed31d5813344850a4fb6ac147455d

See more details on using hashes here.

File details

Details for the file hmlr_frontend_jinja-3.0.0-py3-none-any.whl.

File metadata

File hashes

Hashes for hmlr_frontend_jinja-3.0.0-py3-none-any.whl
Algorithm Hash digest
SHA256 a62f463c2882f5a1ffbb89a412aae6733c7404681ab12e3267c92520bf07f068
MD5 14b515d1b23192bd92eefd2efe05a8ff
BLAKE2b-256 258eb6d614e06c51275b094bdba2d46434fbd2a5e133d6b2f4bbe16e44a96fa1

See more details on using hashes here.

Supported by

AWS Cloud computing and Security Sponsor Datadog Monitoring Depot Continuous Integration Fastly CDN Google Download Analytics Pingdom Monitoring Sentry Error logging StatusPage Status page