A modern html templating library for python
Documentation: https://Ben-Brady.github.io/tempered/
Source Code: https://github.com/Ben-Brady/tempered
pip install tempered
Tempered is templating library designed around HTML and type safety.
- Fast: Sub-millisecond render times.
- Scoped and Bundled CSS: CSS is scoped per file and then bundled together into a single stylesheet per page
- Native Preprocesser Support: Native support for Sass
- Component Based: Each template is a components and can call other components
- Layouts: Templates can use layouts, based on jinja2's implementation
- Dynamically Typed: Optional dynamic type information can be built with components for better intelisense.
Lightning Fast
- Templates are optimised and compiled into Python leading to microsecond long render times.
- 5x faster than Jinja, 50x faster the django
Native CSS
CSS is scoped per componenet and bundled together into a single stylesheet.
<div>
<img src="https://picsum.photos/320/180" alt="Example Post">
</div>
<style lang="sass">
div {
box-sizing: content-box;
width: fit-content;
overflow: hidden;
border-radius: 1rem;
border: .15rem solid black;
img {
height: auto;
width: 10rem;
}
}
</style>
Example
from tempered import Tempered
tempered = Tempered("./templates")
html = tempered.render_template("image.html",
src="/example.png",
alt="Example Post",
)
print(html)
<!-- templates/Image.html -->
{% param src: str %}
{% param alt: str = "" %}
<img src="{{src}}" alt="{{alt}}">
<style>
img {
width: 100px;
height: 100px;
}
</style>
<img alt="Example Post" src="/example.png" class=image-83dc><style>img.image-83dc{width:100px;height:100px}</style>
Metadata
Release files for tempered 0.11.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 | |
|---|---|---|---|
| tempered-0.11.0.tar.gz | 41.7 kB | Details |
Built distribution (wheel)
| File | Interpreter | ABI | Platform | Reset |
|---|---|---|---|---|
| tempered-0.11.0-py3-none-any.whl | Python 3 | none | any | Details |
Total release size: 74.5 kB
Release files / tempered-0.11.0.tar.gz
| Download URL | tempered-0.11.0.tar.gz |
|---|---|
| Size | 41.7 kB |
| Tags | Source |
|
SHA-256 checksum How to use checksums |
ab6e87fc8c29d1ec414649d68b083f7e4a27af9c476f1ff5295956f0ee5cc24c
|
|
BLAKE2b-256 checksum How to use checksums |
e261095cadf2a3f660ef344623e0c4cbb126da3390e04ed4b3c99c8c07fe1362
|
| Upload date | |
|
Uploaded using Trusted Publishing? What is trusted publishing? |
No |
| Uploaded via |
python-requests/2.32.3
|
Release files / tempered-0.11.0-py3-none-any.whl
| Download URL | tempered-0.11.0-py3-none-any.whl |
|---|---|
| Size | 32.8 kB |
| Tags | Python 3 |
|
SHA-256 checksum How to use checksums |
ec33e8055f4f6b40074790f3727411268ac87825fff3a50f4c00ab2127e556d7
|
|
BLAKE2b-256 checksum How to use checksums |
65a8e62a5c4d75be295dd1ee6b6d583c061f237a7289eeea81573047fc175975
|
| Upload date | |
|
Uploaded using Trusted Publishing? What is trusted publishing? |
No |
| Uploaded via |
python-requests/2.32.3
|