Skip to main content

Digital Marketplace Jinja Macros

Python 3.11 Python 3.12 Python 3.13 PyPI version

This repository provides a complete set of Jinja macros that are kept up-to-date and 100% compliant with CCS Digital Marketplace 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, CCS GOV.UK Frontend Frontend release.

This project was inspired by the GOV.UK Frontend Jinja Macros project by HM Land Registry and we thank them for their work which has helped with this project.

Compatibility

The following table shows the version of Digital Marketplace Frontend Jinja that you should use for your targeted version of CCS Digital Marketplace GOV.UK Frontend:

Digital Marketplace Frontend Jinja Version Target CCS Digital Marketplace GOV.UK Frontend Version
5.1.0 4.1.0
5.0.0 4.0.1
4.20.0 3.18.1
4.19.0 3.17.0
4.18.3 3.16.3
4.18.2 3.16.2
4.18.1 3.16.1
4.18.0 3.16.0
4.17.1 3.15.3
4.16.1 3.15.1
4.16.0 3.15.0
4.15.0 3.14.0
4.14.0 3.14.0
4.13.1 3.13.1
4.13.0 3.13.0
4.12.1 3.12.1
4.12.0 3.12.0
4.11.0 3.11.0
4.10.1 3.10.1
4.10.0 3.10.0
4.9.2 3.9.2
4.9.1 3.9.1
4.9.0 3.9.0
4.8.0 3.8.0
4.7.0 3.7.0
4.6.0 3.6.0
4.5.0 3.5.0
4.4.0 3.4.0
4.3.0 3.3.0
4.2.0 3.2.0
4.1.1 3.1.1
4.1.0 3.1.0
4.0.0 3.0.0
3.7.2 2.8.3
3.7.1 2.8.2
3.7.0 2.8.1
3.6.0 2.7.0
3.5.0 2.6.0
3.4.0 2.4.0
3.3.1 2.3.1
3.3.0 2.3.0
3.2.0 2.2.0
3.1.0 2.1.1
3.0.1 2.0.2
2.10.0 1.3.1
2.9.0 1.2.0
2.8.0 1.1.0
2.7.0 1.0.0
2.6.0 6.4.0
2.5.0 6.3.0
2.2.0 6.2.0
2.1.1 6.1.1
2.1.0 6.1.0
2.0.0 6.0.0
1.4.1 5.5.0
1.4.0 5.5.0
1.3.3 5.4.3
1.3.2 5.4.2
1.3.1 5.4.1
1.3.0 5.4.0
1.2.0 5.2.0
1.1.0 5.2.0
1.0.2 5.1.2
1.0.1 5.1.1
1.0.0 5.1.0

Any other versions of CCS Digital Marketplace GOV.UK Frontend not shown above may still be compatible, but have not been specifically tested and verified.

How to use

After running pip install ccs-digitalmarketplace-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"),
            "digitalmarketplace_frontend_jinja": PackageLoader("digitalmarketplace_frontend_jinja"),
          }
        ),
    ]
)

Calling a Macro in your template

To use a component in your project templates you must import and call the component macro and pass the relevant options, for example:

{%- from 'digitalmarketplace_frontend_jinja/components/alert/macro.html' import digitalmarketplaceAlert -%}

{{ digitalmarketplaceAlert({
    "titleText": "Your application is complete",
    "text": "You still have 3 unsubmitted services",
    "type" : "success"
}) }}

The options available to each component macro can be found in the original CCS Digital Marketplace GOV.UK Frontend documentation. Since this project is a like-for-like port, the only difference between the Nunjucks examples and their Jinja equivalents is having to quote key names, e.g. 'text' instead of text.

Versioning

Releases of this project follow semantic versioning, ie

Given a version number MAJOR.MINOR.PATCH, increment the:

  • MAJOR version when you make incompatible API changes,
  • MINOR version when you add functionality in a backwards-compatible manner, and
  • PATCH version when you make backwards-compatible bug fixes.

To make a new version:

  • update the version in the digitalmarketplace_frontend_jinja/__init__.py file
  • if you are making a major change, also update the change log;

When the pull request is merged a GitHub Action will tag the new version.

Pre-commit hooks

This project has a pre-commit hook to do some general file checks and check the pyproject.toml. Follow the Quick start to see how to set this up in your local checkout of this project.

Licence

Unless stated otherwise, the codebase is released under the MIT License. This covers both the codebase and any sample code in the documentation.

The documentation is © Crown copyright and available under the terms of the Open Government 3.0 licence.

Metadata

Release files for ccs-digitalmarketplace-frontend-jinja 5.4.1

For a detailed explanation of source distributions (sdists) and built distributions (wheels), please see the package formats documentation.

Source distribution (sdist)

Source distribution for ccs-digitalmarketplace-frontend-jinja 5.4.1
File Size Uploaded
ccs_digitalmarketplace_frontend_jinja-5.4.1.tar.gz 33.2 kB Details

Built distribution (wheel)

Table of built distributions (wheels) for ccs-digitalmarketplace-frontend-jinja 5.4.1
File Interpreter ABI Platform
ccs_digitalmarketplace_frontend_jinja-5.4.1-py3-none-any.whl Python 3 none any Details

Total release size: 96.5 kB

Release files / ccs_digitalmarketplace_frontend_jinja-5.4.1.tar.gz

Download URL ccs_digitalmarketplace_frontend_jinja-5.4.1.tar.gz
Size 33.2 kB
Tags Source
SHA-256 checksum
How to use checksums
82be714491f35a8ed0736e6437567d40ae8191ac6bab8fbff84c2f2c8bc1210d
BLAKE2b-256 checksum
How to use checksums
947e46ae56b101db17b347b0cea47574874656544fa1cb3f2e2fce17290a0043
Upload date
Uploaded using Trusted Publishing?
What is trusted publishing?
No
Uploaded via twine/7.0.0 CPython/3.11.16

Release files / ccs_digitalmarketplace_frontend_jinja-5.4.1-py3-none-any.whl

Download URL ccs_digitalmarketplace_frontend_jinja-5.4.1-py3-none-any.whl
Size 63.3 kB
Tags Python 3
SHA-256 checksum
How to use checksums
3690641f6f515090118efd38f648bc0ebdd8b2f8191f9d319be6ca9e33928b69
BLAKE2b-256 checksum
How to use checksums
85ea002178eff01c83dfe3bd6bafea4712c87c7a911bacaf2da47f432810ac8c
Upload date
Uploaded using Trusted Publishing?
What is trusted publishing?
No
Uploaded via twine/7.0.0 CPython/3.11.16

Release history Release notifications | RSS feed

This release

5.4.1 This release

2 release files

5.4.0

2 release files

5.3.0

2 release files

5.2.0

2 release files

5.1.0

2 release files

5.0.0

2 release files

4.20.0

2 release files

4.19.0

2 release files

4.18.3

2 release files

4.18.2

2 release files

4.17.1

2 release files

4.16.2

2 release files

4.13.1

2 release files

4.13.0

2 release files

4.12.1

2 release files

4.12.0

2 release files

4.10.1

2 release files

4.10.0

2 release files

4.9.2

2 release files

4.9.1

2 release files

4.9.0

2 release files

4.8.0

2 release files

4.7.0

2 release files

4.6.0

2 release files

4.5.0

2 release files

4.4.0

2 release files

4.3.0

2 release files

4.2.0

2 release files

4.1.1

2 release files

4.1.0

2 release files

4.0.0

2 release files

3.7.2

2 release files

3.7.1

2 release files

3.7.0

2 release files

3.6.0

2 release files

3.5.0

2 release files

3.4.0

2 release files

3.3.2

2 release files

3.3.1

2 release files

3.3.0

2 release files

3.2.0

2 release files

3.1.0

2 release files

3.0.2

2 release files

3.0.1

2 release files

3.0.0

2 release files

2.10.0

2 release files

2.9.0

2 release files

2.8.0

2 release files

2.7.0

2 release files

2.6.0

2 release files

2.5.0

2 release files

2.4.0

2 release files

2.3.0

2 release files

2.2.0

2 release files

2.1.1

2 release files

2.1.0

2 release files

2.0.0

2 release files

1.4.1

2 release files

1.4.0

2 release files

1.3.3

2 release files

1.3.2

2 release files

1.3.1

2 release files

1.3.0

2 release files

1.2.0

2 release files

1.1.0

2 release files

1.0.2

2 release files

1.0.1

2 release files

1.0.0

2 release files

Anthropic, PBC Visionary sponsor Bloomberg Visionary sponsor Hudson River Trading Visionary sponsor Meta Visionary sponsor NVIDIA Visionary sponsor Microsoft Sustainability sponsor Depot Continuous Integration AWS Cloud computing and Security Sponsor Datadog Monitoring Fastly CDN Google Download Analytics Sentry Error logging StatusPage Status page