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>
Download files
Download the file for your platform. If you're not sure which to choose, learn more about installing packages.
Source Distribution
tempered-0.11.0.tar.gz
(41.7 kB
view details)
Built Distribution
Filter files by name, interpreter, ABI, and platform.
If you're not sure about the file name format, learn more about wheel file names.
Copy a direct link to the current filters
tempered-0.11.0-py3-none-any.whl
(32.8 kB
view details)
File details
Details for the file tempered-0.11.0.tar.gz.
File metadata
- Download URL: tempered-0.11.0.tar.gz
- Upload date:
- Size: 41.7 kB
- Tags: Source
- Uploaded using Trusted Publishing? No
- Uploaded via:
python-requests/2.32.3
File hashes
| Algorithm | Hash digest | |
|---|---|---|
| SHA256 |
ab6e87fc8c29d1ec414649d68b083f7e4a27af9c476f1ff5295956f0ee5cc24c
|
|
| MD5 |
ec616f8cce98b3ea258de13cf675fbdb
|
|
| BLAKE2b-256 |
e261095cadf2a3f660ef344623e0c4cbb126da3390e04ed4b3c99c8c07fe1362
|
File details
Details for the file tempered-0.11.0-py3-none-any.whl.
File metadata
- Download URL: tempered-0.11.0-py3-none-any.whl
- Upload date:
- Size: 32.8 kB
- Tags: Python 3
- Uploaded using Trusted Publishing? No
- Uploaded via:
python-requests/2.32.3
File hashes
| Algorithm | Hash digest | |
|---|---|---|
| SHA256 |
ec33e8055f4f6b40074790f3727411268ac87825fff3a50f4c00ab2127e556d7
|
|
| MD5 |
6ed923dd1eecae8c302bb37514359f91
|
|
| BLAKE2b-256 |
65a8e62a5c4d75be295dd1ee6b6d583c061f237a7289eeea81573047fc175975
|