GOV.UK Frontend Jinja Macros
Project description
GOV.UK Frontend Jinja Macros
This repository provides a complete set of Jinja macro ports that are kept up-to-date and 100% compliant with the GOV.UK Frontend Nunjucks macros. Porting is intentionally manual rather than automated to make updates simpler than maintaining an automated conversion routine. A comprehensive test suite ensures compliance against the latest, and every subsequent, GOV.UK Frontend release.
- Package: https://pypi.org/project/govuk-frontend-jinja/
- Demo app: https://github.com/LandRegistry/govuk-frontend-jinja-demo
- Live demo: https://govuk-frontend-jinja.herokuapp.com/
How to use
After running pip install govuk-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('app'),
PrefixLoader({
'govuk_frontend_jinja': PackageLoader('govuk_frontend_jinja')
})
])
Running the tests
The tests are run in a GitHub actions pipeline but if you want to run them locally you will need to install govuk-frontend-diff.
There is a test server at tests/utils/app.py
which you will need to run using the following command:
(cd tests/utils && python -m flask run --port 3000)
You can then run the tests using govuk-frontend-diff
as follows:
./govuk-frontend-diff http://localhost:3000 --govuk-frontend-version=v3.11.0
This is all wrapped up in ./test.sh
for simplified running (Requires Docker).
Versioning
We use SemVer for versioning. For the versions available, see the tags on this repository.
Contributors
- Matt Shaw (Primary maintainer)
- Andy Mantell (Original author)
Project details
Release history Release notifications | RSS feed
Download files
Download the file for your platform. If you're not sure which to choose, learn more about installing packages.
Source Distribution
Built Distribution
Hashes for govuk-frontend-jinja-1.2.0.tar.gz
Algorithm | Hash digest | |
---|---|---|
SHA256 | bb6c4a23fe1f8987fe565afbc7082cb984be3005255e21122caaadd2e33e574c |
|
MD5 | 5c40e98eaeb31fd6019f0e69074e9743 |
|
BLAKE2b-256 | 0046e45cae3c93e5e89231158a13f1aeb399673a6e14940f9bada5ed84448379 |
Hashes for govuk_frontend_jinja-1.2.0-py3-none-any.whl
Algorithm | Hash digest | |
---|---|---|
SHA256 | a7b60b787011defc39c72ffe0cc578c2eed50b044a79f3e75397cd8492c2eac5 |
|
MD5 | 2ae7758b10e62c58fcca977bf3fb955d |
|
BLAKE2b-256 | 2fbe7fa55ddd1cb98e9226600852e75a0821beb5e13b05bb7b435eeb35fd04e0 |