Skip to main content

HMLR Frontend Jinja Macros

Project description

HMLR Frontend Jinja Macros

PyPI version hmlr-frontend 1.0.0 Python package

This repository provides a complete set of Jinja macros that are kept up-to-date and 100% compliant with the original HMLR Frontend Nunjucks macros. Porting is intentionally manual rather than automated to make updates simpler than maintaining an automated conversion routine.

Compatibility

The following table shows the version of HMLR Frontend Jinja that you should use for your targeted version of HMLR Frontend:

HMLR Frontend Jinja Version Target HMLR Frontend Version
1.0.0 1.1.0
0.2.0 1.0.0-rc1

Any other versions of HMLR Frontend not shown above may still be compatible, but have not been specifically tested and verified.

How to use

After running pip install hmlr-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({"hmlr_frontend_jinja": PackageLoader("hmlr_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 'hmlr_frontend_jinja/components/header/macro.html' import hmlrHeader -%}

{{ hmlrHeader({
  'serviceName': "Service name",
  'serviceUrl': "#"
}) }}

The options available to each component macro can be found in the original HMLR Design System Components 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

We use SemVer for versioning. For the versions available, see the tags on this repository.

How to contribute

We welcome contribution from the community. If you want to contribute to this project, please review the code of conduct and contribution guidelines.

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

hmlr-frontend-jinja-1.0.0.tar.gz (4.9 kB view details)

Uploaded Source

Built Distribution

hmlr_frontend_jinja-1.0.0-py3-none-any.whl (5.4 kB view details)

Uploaded Python 3

File details

Details for the file hmlr-frontend-jinja-1.0.0.tar.gz.

File metadata

  • Download URL: hmlr-frontend-jinja-1.0.0.tar.gz
  • Upload date:
  • Size: 4.9 kB
  • Tags: Source
  • Uploaded using Trusted Publishing? No
  • Uploaded via: twine/4.0.1 CPython/3.11.0

File hashes

Hashes for hmlr-frontend-jinja-1.0.0.tar.gz
Algorithm Hash digest
SHA256 cd0b8a8646b860471eb516202e6f1c81753409807e130dd39396297b7dc8f37c
MD5 3aa1b0fdfb1a91b6a088f6d5caae5c78
BLAKE2b-256 4cae62c3bf5cff40f17df750ac3f2f3d9b1f7eae547b15d3068c50b77ef2bd50

See more details on using hashes here.

File details

Details for the file hmlr_frontend_jinja-1.0.0-py3-none-any.whl.

File metadata

File hashes

Hashes for hmlr_frontend_jinja-1.0.0-py3-none-any.whl
Algorithm Hash digest
SHA256 c017c9ece804ce7eecb54f05f128cad96e385b8008a4cbc6c3d24c4d04dd59a8
MD5 6a5ce434212d587d7ee91b53fc458715
BLAKE2b-256 65ff879a056b126dba0ad1c11172b85e0c229cf5b48710e18459d132f79b47c6

See more details on using hashes here.

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