Generate native python functions from HTML templates
Project description
Tempered (Beta)
Convert html templates into native python components
pip install tempered
Documentation | PyPi | Github |
---|
Features
- Fast
- Roughly 5x faster than jinja, 50x faster than django
- Scoped CSS
- CSS is scoped per component
- Component Based
- Each template is a components and can call other components
- Layouts
- Templates can use layouts, based on jinja2's implementation
- Intelisense
- Components have dynamically created type information providing intelisense support
- Type Checked
- Static builds can be checked by static analysers such as mypy
Example
<!-- templates/Image.html -->
{% param src: str %}
{% param alt: str = "" %}
<img src="{{src}}" alt="{{alt}}">
<style>
img {
width: 100px;
height: 100px;
}
</style>
from tempered import Tempered
env = Tempered("./templates").build_enviroment()
print(env.render_template("image.html",
src="/example.png",
alt="Example Post",
))
<img alt="Example Post" src=/example.png class=image-83dc><style>img.image-83dc{width:100px;height:100px}</style>
Transpiled
Templates are transpiled inmto python functions, this provides increased performance.
Type Hinted
Optional python type information is dynamically created when compiling templates. This means whilst developing you can be provided type information about parameters and existing templates automatically.
Project details
Release history Release notifications | RSS feed
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.9.1.tar.gz
(32.6 kB
view hashes)
Built Distribution
tempered-0.9.1-py3-none-any.whl
(34.8 kB
view hashes)