Skip to main content

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.

Full Page Benchmark Partials Benchmark Static Page Benchmark

View Benchmarks Here

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.

Type Hinting.webm

Project details


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)

Uploaded Source

Built Distribution

tempered-0.9.1-py3-none-any.whl (34.8 kB view hashes)

Uploaded Python 3

Supported by

AWS AWS Cloud computing and Security Sponsor Datadog Datadog Monitoring Fastly Fastly CDN Google Google Download Analytics Microsoft Microsoft PSF Sponsor Pingdom Pingdom Monitoring Sentry Sentry Error logging StatusPage StatusPage Status page