Skip to main content

A port of NHS.UK frontend templates for the Jinja templating engine.

Project description

NHS.UK frontend jinja templates

A Jinja implementation of the NHS.UK frontend components.

NHS.UK frontend contains the code you need to start building user interfaces for NHS websites and services.

Installation

We have not yet set up publishing to the Python Package Index (PyPI). In the meantime, you can install directly from GitHub:

pip install nhsuk-frontend-jinja

Compatibility

The following table shows the version of NHS.UK frontend jinja that you should use for your targeted version of NHS.UK frontend:

NHS.UK frontend version NHS.UK frontend jinja version
9.3.0 0.1.0

Usage

Visit the NHS digital service manual for examples of components and guidance for when to use them.

These templates require you to configure your Jinja environment to use ChainableUndefined and the package loader.

Flask example:

from jinja2 import FileSystemLoader, PackageLoader, ChainableUndefined

app.jinja_options = {
    "undefined": ChainableUndefined,  # This is needed to prevent jinja from throwing an error when chained parameters are undefined
    "loader": ChoiceLoader(
        [
            FileSystemLoader(PATH_TO_YOUR_TEMPLATES),
            PackageLoader("nhsuk_frontend_jinja"),
        ]
    ),
}

Plain Jinja example

from jinja2 import FileSystemLoader, PackageLoader, ChainableUndefined

jinja_env = Environment(
    undefined=ChainableUndefined,
    loader=ChoiceLoader(
        FileSystemLoader(PATH_TO_YOUR_TEMPLATES),
        PackageLoader("nhsuk_frontend_jinja"),
    ),
    **options)

All our macros take identical arguments to the Nunjucks ones, except you need to quote the parameter names.

{% from 'components/warning-callout/macro.jinja' import warningCallout %}

{{ warningCallout({
  "heading": "Quotey McQuoteface",
  "HTML": "<p>Don't forget to quote your parameter names!</p>"
}) }}

Note that all macro paths must be prefixed with components/ and have the .jinja extension.

Contribute

Read our contributing guidelines to contribute to NHS.UK frontend jinja.

Development environment

Gitpod ready-to-code

Get in touch

This repo is maintained by NHS England. Open a GitHub issue if you need to get in touch.

Licence

The codebase is released under the MIT Licence, unless stated otherwise. This covers both the codebase and any sample code in the documentation. The documentation is © NHS England and available under the terms of the Open Government 3.0 licence.

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

nhsuk_frontend_jinja-0.1.0.tar.gz (67.7 kB view details)

Uploaded Source

Built Distribution

If you're not sure about the file name format, learn more about wheel file names.

nhsuk_frontend_jinja-0.1.0-py3-none-any.whl (125.0 kB view details)

Uploaded Python 3

File details

Details for the file nhsuk_frontend_jinja-0.1.0.tar.gz.

File metadata

  • Download URL: nhsuk_frontend_jinja-0.1.0.tar.gz
  • Upload date:
  • Size: 67.7 kB
  • Tags: Source
  • Uploaded using Trusted Publishing? Yes
  • Uploaded via: twine/6.1.0 CPython/3.12.9

File hashes

Hashes for nhsuk_frontend_jinja-0.1.0.tar.gz
Algorithm Hash digest
SHA256 889a4357258fa2b0727f9c406a6ff88eed880e9641a8b9455fbfad320a07d7fc
MD5 d230132175f1d7039f9c934e5d058cfb
BLAKE2b-256 cd9e52dc756d7d1ec37406f787bb341ee8d74e52c8250d30dea34656b421e671

See more details on using hashes here.

Provenance

The following attestation bundles were made for nhsuk_frontend_jinja-0.1.0.tar.gz:

Publisher: publish.yml on NHSDigital/nhsuk-frontend-jinja

Attestations: Values shown here reflect the state when the release was signed and may no longer be current.

File details

Details for the file nhsuk_frontend_jinja-0.1.0-py3-none-any.whl.

File metadata

File hashes

Hashes for nhsuk_frontend_jinja-0.1.0-py3-none-any.whl
Algorithm Hash digest
SHA256 503961cb30a6c355ff63650687d7c26c9ac7b0ced9f17049ed371c96471cf52d
MD5 6bc8f5f059bc8934e62bfae48fa8b9fa
BLAKE2b-256 6653e97a831e324bcc3bac2bc073bc2762c01989477d7388cb43016e4c3885b3

See more details on using hashes here.

Provenance

The following attestation bundles were made for nhsuk_frontend_jinja-0.1.0-py3-none-any.whl:

Publisher: publish.yml on NHSDigital/nhsuk-frontend-jinja

Attestations: Values shown here reflect the state when the release was signed and may no longer be current.

Supported by

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