Jinja Tools
A tool to help you logically separate how things are rendered in your project. For example, you may want to have smaller templates rendered within larger templates.
Register the Blueprint
To enable the features of the package, you must register the flask blueprint.
from flask import Flask import jinja_subrender app = Flask() app.register_blueprint(jinja_subrender.bp)
Sub-Render Example
You may have a jinja-template that displays a collection of items, called ‘all_items.jinja’. You may also have a jinja-templte for how each item should be rendered, called ‘item.jinja’.
In this case your ‘all_items.jinja’ template could look something like:
{% extends "main.jinja" %}
{% block content %}
{% for item in items %}
<div>
{{ item | Render('item.jinja') }}
</div>
{% endfor %}
{% endblock %}
The ‘item.jinja’ template could look something like:
<div>
{{ obj['name'] }}
<img src="{{ obj['src'] }}"/>
</div>
Note: Render() always passes the item as ‘obj’, but you can rename within the jinja template, like so:
{% set item = obj %}
<div>
{{ item['name'] }}
<img src="{{ item['src'] }}"/>
</div>
Passing multiple arguments
You can also pass multiple arguments by passing them as a tuple in the super-template. For example, ‘all_items.jinja’ could look like:
{% set total = items | length %}
{% for item in items %}
<div>
{{ (item, total) | Render('item.jinja') }}
</div>
{% endfor %}
You can then access the second argument in the sub-template by breaking it apart with ‘set’
{% set item, total = obj %}
<div>
{{ item['name'] }}
<img src="{{ item['src'] }}"/>
total = {{ total }}
</div>
Metadata
Release files for jinja-subrender 0.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 |
|---|---|---|---|---|
| jinja_subrender-0.0.1.tar.gz | 2.6 kB | Without provenance | Details for jinja_subrender-0.0.1.tar.gz |
Built distribution (wheel)
| File | Interpreter | ABI | Platform | Actions Reset |
|---|---|---|---|---|
| jinja_subrender-0.0.1-py3-none-any.whl | Python 3 | none | any | Details for jinja_subrender-0.0.1-py3-none-any.whl |
Total release size: 5.1 kB
Release files / jinja_subrender-0.0.1.tar.gz
| Download URL | jinja_subrender-0.0.1.tar.gz |
|---|---|
| Size | 2.6 kB |
| Tags | Source |
|
SHA-256 checksum How to use checksums |
4831624b860a5ae6961b02fa8f142d64992d738c9dfe51d86e8f05919b6926da
|
|
BLAKE2b-256 checksum How to use checksums |
c6a0d1660457c25a22eda680d368114f9f27134e6212ae1ff9193b542bafb9b6
|
| Upload date | |
|
Uploaded using Trusted Publishing? What is trusted publishing? |
No |
| Uploaded via |
twine/3.7.1 importlib_metadata/4.10.0 pkginfo/1.8.2 requests/2.26.0 requests-toolbelt/0.9.1 tqdm/4.62.3 CPython/3.8.2
|
Release files / jinja_subrender-0.0.1-py3-none-any.whl
| Download URL | jinja_subrender-0.0.1-py3-none-any.whl |
|---|---|
| Size | 2.5 kB |
| Tags | Python 3 |
|
SHA-256 checksum How to use checksums |
77120cd9592f4d7aed8b29ebb65e6b841110bf7a35493ddcce962b60cd698b3a
|
|
BLAKE2b-256 checksum How to use checksums |
ea9e7d6adf2d1ce1401026786b34319a9b1cc04bfd0ed45b1af492b83380d6ed
|
| Upload date | |
|
Uploaded using Trusted Publishing? What is trusted publishing? |
No |
| Uploaded via |
twine/3.7.1 importlib_metadata/4.10.0 pkginfo/1.8.2 requests/2.26.0 requests-toolbelt/0.9.1 tqdm/4.62.3 CPython/3.8.2
|
Security for jinja-subrender 0.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.