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.10.2
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.1.0.tar.gz
Algorithm | Hash digest | |
---|---|---|
SHA256 | a1b2deefee24d20c35d0ff6d3f85aaec1b5c3600d717f7be3d62631c1a48131a |
|
MD5 | 7f9aa031676fe0ed6379b116968943c5 |
|
BLAKE2b-256 | f416c4e3efefcc3d5fb95235d4b97a695ae4d99572855a8b6cec9c8f950bf431 |
Hashes for govuk_frontend_jinja-1.1.0-py3-none-any.whl
Algorithm | Hash digest | |
---|---|---|
SHA256 | 8692337161f78f3df06d66fe5c27ee0ca2d4d377c1ee207f5ae996277c6af970 |
|
MD5 | 2e88d54e68d2c67e6c7565018b8a397f |
|
BLAKE2b-256 | aadd5dc4a58bb0762e054e487f2e159d431c0f734ce8c4f0e82086a9bcaf08e5 |