Yet Another Template Language
This is the web2py template language described here made available as stand alone package so it can be used anywhere.
Basically it is pure Python within "{{" ... "}}" delimiters and blocks are terminated with "pass" if termination is not obvious. There is no indentation constraints.
For example:
from yatl import render, SPAN
example = """
<div>
{{ for k in range(num): }}
<span>{{=SPAN(k, _class='number')}} is {{if k % 2 == 0:}}even{{else:}}odd{{pass}}</span>
{{ pass }}
</div>
"""
print(render(example, context=dict(num=10, SPAN=SPAN), delimiters="{{ }}"))
In the example SPAN is an optional helper. Output is escaped by default unless marked up with the XML helper as in {{=XML('1 < 2')}}. Note that the helpers included here are similar but not identical to the web2py ones. They are 99% compatible but the implementation is different.
Any Python expressions is allowed in templates, including function and class defintions:
example = """
{{ def link(x): }}<a href="{{=x}}">{{=x}}</a>{{ pass }}
<ul>
{{ for k in range(num): }}
<li>
{{= link('http://example.com/%s' % k) }}
</li>
{{ pass }}
</ul>
"""
print(render(example, context=dict(num=10), delimiters="{{ }}"))
Caching
If you implement a caching reader as the one below, you mak yatl even faster:
CACHE = {}
def reader(filename):
if filename in CACHE:
return CACHE[filename]
with open(filename) as fp;
CACHE[filename] = content = fp.read()
return content
output = yatl.render(reader(filename), path=path, reader=reader)
Metadata
Release files for yatl 20260805.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 |
|---|---|---|---|---|
| yatl-20260805.1.tar.gz | 22.8 kB | Without provenance | Details for yatl-20260805.1.tar.gz |
Built distribution (wheel)
| File | Interpreter | ABI | Platform | Actions Reset |
|---|---|---|---|---|
| yatl-20260805.1-py3-none-any.whl | Python 3 | none | any | Details for yatl-20260805.1-py3-none-any.whl |
Total release size: 42.2 kB
Release files / yatl-20260805.1.tar.gz
| Download URL | yatl-20260805.1.tar.gz |
|---|---|
| Size | 22.8 kB |
| Tags | Source |
|
SHA-256 checksum How to use checksums |
ca09b1a4be97dece288db44a98dbdd3070f889381e503bc5be7603829879e92e
|
|
BLAKE2b-256 checksum How to use checksums |
33bf5456f2fa12811b4ce4dd82741ad781d834ff4f4865b75f775e50c3e9ac3e
|
| Upload date | |
|
Uploaded using Trusted Publishing? What is trusted publishing? |
No |
| Uploaded via |
twine/7.0.0 CPython/3.13.12
|
Release files / yatl-20260805.1-py3-none-any.whl
| Download URL | yatl-20260805.1-py3-none-any.whl |
|---|---|
| Size | 19.4 kB |
| Tags | Python 3 |
|
SHA-256 checksum How to use checksums |
12222e2b0b9d38113ef9d61c230ca572a738727f8b91457cea703d0e99ae31b5
|
|
BLAKE2b-256 checksum How to use checksums |
29ed0176cb9cec10fbce6ef74a31150b5f6e5e125864efe472becf14d7ad1cff
|
| Upload date | |
|
Uploaded using Trusted Publishing? What is trusted publishing? |
No |
| Uploaded via |
twine/7.0.0 CPython/3.13.12
|
Security for yatl 20260805.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.