Jinja Layout
Easier layouts for Jinja templates.
Installation
pip install jinja-layout
Usage
The jinja_layout.LayoutExtension needs to be added to your environment:
from jinja2 import Environment, PackageLoader
env = Environment(loader=PackageLoader(__name__, 'templates'))
env.add_extension('jinja_layout.LayoutExtension')
Jinja-layout introduces the use_layout directive. There are two
optional arguments:
- a template name to extend from (default: "layout.html")
- the name of the default block to override (default: "content")
You can change the default layout template using the defaut_layout
attribute on your environment and the default block name using
the default_layout_block attribute.
This directive is similar to Jinja's extends directive but does
not require the use of blocks. The content which is not used in
blocks, will be automatically wrapped in a block. The name of this
block is defined by the second argument of the directive.
Example
Let's consider the following layout saved as layout.html:
<html>
<head>{% block head %}{% endblock %}</head>
<body>{% block content %}{% endblock %}</body>
</html>
Basic layout example:
{% use_layout %}
hello world
Overriding the header block:
{% use_layout %}
{% block head %}<title>example</title>{% endblock %}
hello world
Using blocks all the way:
{% use_layout %}
{% block head %}<title>example</title>{% endblock %}
{% block content %}hello world{% endblock %}
Metadata
Release files for jinja-layout 0.5.0
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 |
|---|---|---|---|---|
| jinja_layout-0.5.0.tar.gz | 2.3 kB | Without provenance | Details for jinja_layout-0.5.0.tar.gz |
Built distribution (wheel)
| File | Interpreter | ABI | Platform | Actions Reset |
|---|---|---|---|---|
| jinja_layout-0.5.0-py3-none-any.whl | Python 3 | none | any | Details for jinja_layout-0.5.0-py3-none-any.whl |
Total release size: 5.3 kB
Release files / jinja_layout-0.5.0.tar.gz
| Download URL | jinja_layout-0.5.0.tar.gz |
|---|---|
| Size | 2.3 kB |
| Tags | Source |
|
SHA-256 checksum How to use checksums |
80c3120e3726d14b652ff3a1976f6cf44ec568897fcf8bd0c20451e5f03929f0
|
|
BLAKE2b-256 checksum How to use checksums |
f30d481d4625bd0a5babeb4a60022288d5da535645a26433605c1726b0762df5
|
| Upload date | |
|
Uploaded using Trusted Publishing? What is trusted publishing? |
No |
| Uploaded via |
uv/0.8.17
|
Release files / jinja_layout-0.5.0-py3-none-any.whl
| Download URL | jinja_layout-0.5.0-py3-none-any.whl |
|---|---|
| Size | 3.0 kB |
| Tags | Python 3 |
|
SHA-256 checksum How to use checksums |
1845764ef809541c0c12c0c23e4ff70e259e1e4d789ebeeaaaefba55e09d25b7
|
|
BLAKE2b-256 checksum How to use checksums |
2c95c4a71f5d33a48b88c58aab67bfe4623aa8b482bb703d8142ee47f0d04a3b
|
| Upload date | |
|
Uploaded using Trusted Publishing? What is trusted publishing? |
No |
| Uploaded via |
uv/0.8.17
|
Security for jinja-layout 0.5.0
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.