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/
- Example app: https://github.com/matthew-shaw/govuk-frontend-jinja-example
- 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.8.1
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.0.0.tar.gz
Algorithm | Hash digest | |
---|---|---|
SHA256 | 4e19163bd27013c88fd24dc943cd2c885b1ae49a0d1ae99e78c13902939ed69d |
|
MD5 | a00ef6c10d14a090560e1bca62b093da |
|
BLAKE2b-256 | df4ada6637c04c01eaa1e553a04687da6b3109bdfcda35037c0a598c427ba855 |
Hashes for govuk_frontend_jinja-1.0.0-py3-none-any.whl
Algorithm | Hash digest | |
---|---|---|
SHA256 | c1ca3efa5e0b34d49a9e1a401f3ec29e95a1343a94955c1dc6ca1fd423ede77f |
|
MD5 | fdf9e3e81b8bd79b27c5afdd6e6b79cc |
|
BLAKE2b-256 | 329d71ad175995f260b6903c5fe92e8ea3ab3b8e1d5c8f2df502c1e9ff41fb53 |