Fastapi Jinja theming system.
Include Block Tag
This template system heavily uses the include_block tag. This tag will include an html file as a block. This tag can be overridden with an html file matching the name or by a block tag matching the base name.
Create a base for your theme
{# theme_templates/theme/base.html #}
<html>
<body>
{% include_block "theme/sidenav.html" %}
{% block contents %}
<h1>Hello World!</h1>
{% endblock %}
</body>
</html>
Normal navigation for your theme
{# theme_templates/theme/sidenav.html #}
<ul>
<li><a href="/">Home</a></li>
<li><a href="/page1">Page 1</a></li>
<li><a href="/page2">Page 2</a></li>
</ul>
Override with block
Override navigation by using a block. The block name will be the same as the base html filename. Note: different templates directory
{# templates/main.html #}
{% extends "theme/base.html" %}
{% block sidenav %}
<ul>
<li>Hello</li>
</ul>
{% endblock sidenav %}
Override with HTML file
Alternatively you can override by using an html file. Note: different templates directory
{# templates/theme/sidenav.html #}
<ul>
<li><a href="/">Home</a></li>
<li><a href="/link">Link to my other site</a></li>
</ul>
Fastapi using the templates
from fastapi import FastAPI, Request
from justengel_theme import ThemeTemplates
MYD_DIR = os.path.dirname(__file__)
# Search for project files first
project_dir = os.path.join(MY_DIR, 'templates')
templates = ThemeTemplates(project_dir)
# Search for theme files if project files are not found
theme_dir = os.path.join(MY_DIR, 'theme_templates')
templates.add_directory(theme_dir)
app = FastAPI()
@app.get('/')
def index(request: Request):
return material.TemplateResponse('main.html', {'request': request})
Metadata
Release files for justengel-theme 1.0.1
For a detailed explanation of source distributions (sdists) and built distributions (wheels), please see the package formats documentation.
Source distribution (sdist)
| File | Size | Uploaded | Provenance | Actions |
|---|---|---|---|---|
| justengel_theme-1.0.1.tar.gz | 9.7 kB | Without provenance | Details for justengel_theme-1.0.1.tar.gz |
Built distribution (wheel)
| File | Interpreter | ABI | Platform | Actions Reset |
|---|---|---|---|---|
| justengel_theme-1.0.1-py3-none-any.whl | Python 3 | none | any | Details for justengel_theme-1.0.1-py3-none-any.whl |
Total release size: 19.9 kB
Release files / justengel_theme-1.0.1.tar.gz
| Download URL | justengel_theme-1.0.1.tar.gz |
|---|---|
| Size | 9.7 kB |
| Tags | Source |
|
SHA-256 checksum How to use checksums |
cac4b96ab11b0e136e47c7bac9b1181dbb7b73f16b2ba08791e608bfc26010b3
|
|
BLAKE2b-256 checksum How to use checksums |
79cbbfcc8968de3c0b7bd625c622a7c174b948fb983cc31ddbbf6c87f13e1e38
|
| Upload date | |
|
Uploaded using Trusted Publishing? What is trusted publishing? |
No |
| Uploaded via |
twine/3.8.0 pkginfo/1.8.2 readme-renderer/32.0 requests/2.27.1 requests-toolbelt/0.9.1 urllib3/1.26.8 tqdm/4.63.0 importlib-metadata/4.11.2 keyring/23.5.0 rfc3986/1.5.0 colorama/0.4.4 CPython/3.9.7
|
Release files / justengel_theme-1.0.1-py3-none-any.whl
| Download URL | justengel_theme-1.0.1-py3-none-any.whl |
|---|---|
| Size | 10.2 kB |
| Tags | Python 3 |
|
SHA-256 checksum How to use checksums |
5183ac2b6167f55ba5fbf97f6c3db69eab7fa3f430c07c0c70916fac5016dd51
|
|
BLAKE2b-256 checksum How to use checksums |
e07daa2d5a26e6368b4f10971636a15fffa516da546efc75a1138de892adbe9c
|
| Upload date | |
|
Uploaded using Trusted Publishing? What is trusted publishing? |
No |
| Uploaded via |
twine/3.8.0 pkginfo/1.8.2 readme-renderer/32.0 requests/2.27.1 requests-toolbelt/0.9.1 urllib3/1.26.8 tqdm/4.63.0 importlib-metadata/4.11.2 keyring/23.5.0 rfc3986/1.5.0 colorama/0.4.4 CPython/3.9.7
|
Security for justengel-theme 1.0.1
Provenance
Provenance describes where a file came from. On PyPI, provenance is shared via attestations, which provide a verifiable record of the build or publishing details. View details, limitations and caveats.
No provenance found
None of the files in this release were uploaded with provenance metadata.
A note on package security
PyPI is a repository for distributing packages, not a service for auditing them. While third-party security researchers and our staff do their best to detect and remove malicious packages, PyPI cannot guarantee the quality, security or suitability of any given package.
To learn more about protecting yourself from malicious actors, visit our package security documentation.