HMLR Frontend Jinja Macros
Project description
HMLR Frontend Jinja Macros
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 |
---|---|
2.0.0 | 2.0.0 |
1.1.0 | 1.4.0 |
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
- Matt Shaw (Author and primary maintainer)
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
File details
Details for the file hmlr_frontend_jinja-2.0.0.tar.gz
.
File metadata
- Download URL: hmlr_frontend_jinja-2.0.0.tar.gz
- Upload date:
- Size: 4.9 kB
- Tags: Source
- Uploaded using Trusted Publishing? No
- Uploaded via: twine/5.1.0 CPython/3.12.3
File hashes
Algorithm | Hash digest | |
---|---|---|
SHA256 | 3385ab228d7fa8dbead36927e5cbb931e07870b594bd923f52da75c35b4ae077 |
|
MD5 | 2575687e4c8dcf93bc8d1b831bce45c0 |
|
BLAKE2b-256 | 5e64d103d9bb3391619f969198e16f667d1983a70f85474a8fb05353364baf1e |
File details
Details for the file hmlr_frontend_jinja-2.0.0-py3-none-any.whl
.
File metadata
- Download URL: hmlr_frontend_jinja-2.0.0-py3-none-any.whl
- Upload date:
- Size: 5.4 kB
- Tags: Python 3
- Uploaded using Trusted Publishing? No
- Uploaded via: twine/5.1.0 CPython/3.12.3
File hashes
Algorithm | Hash digest | |
---|---|---|
SHA256 | 7655474fcc8bd134bad8b189b962c27e3355440b90bf6650776ac18f3fbf4ba7 |
|
MD5 | adc40bb28ca53126e9cf4c03ee4ab97c |
|
BLAKE2b-256 | e65ba0f3c3fb6e2ca1e6ac7d03d245c1e777d9659b42d132bc855a5b219afa2c |