Skip to main content

GOV.UK Frontend Jinja Macros

Project description

GOV.UK Frontend Jinja Macros

PyPI version govuk-frontend 3.7.0 Test

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

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

govuk-frontend-jinja-0.2.1.tar.gz (18.7 kB view hashes)

Uploaded Source

Built Distribution

govuk_frontend_jinja-0.2.1-py3-none-any.whl (30.9 kB view hashes)

Uploaded Python 3

Supported by

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