GOV.UK Frontend Jinja Macros
Project description
GOV.UK Frontend Jinja Macros
This repository contains Jinja macro ports of the GOV.UK Frontend. This is currently up to date with release v3.7.0.
How to use
Here is a simple example Flask app that demonstrates how to import and use the GOV.UK Jinja macros.
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__)
loader = ChoiceLoader([
PackageLoader('app'),
PrefixLoader({
'govuk_frontend_jinja': PackageLoader('govuk_frontend_jinja')
})
])
app.jinja_loader = loader
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.7.0
This is all wrapped up in ./test.sh
for simplified running.
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-0.2.1.tar.gz
Algorithm | Hash digest | |
---|---|---|
SHA256 | 2ee1bd843901e9046a0b6d84aa7d0566b2ae6948480ce87d4738f81938a0304e |
|
MD5 | 48c1a4ab2f788875ddc47500c9da94f3 |
|
BLAKE2b-256 | 577001e6be2aac2d74645f074b1a798335578feddaa4654c777ca69fd1a61447 |
Hashes for govuk_frontend_jinja-0.2.1-py3-none-any.whl
Algorithm | Hash digest | |
---|---|---|
SHA256 | 2bbfddf44c0df2d42c56310b587bd72c389f9935bcd50dc528c4287c02bb6840 |
|
MD5 | 1b610ded4e1eab70edcd6f23bb62ac45 |
|
BLAKE2b-256 | d7404d639f2f1d5b74a39c2f7153a8bfe642c61f155f48ec8d560699f61330c4 |