Skip to main content

A fast, strongly typed html templating library for python

Project description

Tempered Banner

A modern html templating library for python

Test Package version Supported Python versions


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
Full Page Benchmark Partials Benchmark Static Page Benchmark

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>

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.11.0.tar.gz (41.7 kB view details)

Uploaded Source

Built Distribution

If you're not sure about the file name format, learn more about wheel file names.

tempered-0.11.0-py3-none-any.whl (32.8 kB view details)

Uploaded Python 3

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

Hashes for tempered-0.11.0.tar.gz
Algorithm Hash digest
SHA256 ab6e87fc8c29d1ec414649d68b083f7e4a27af9c476f1ff5295956f0ee5cc24c
MD5 ec616f8cce98b3ea258de13cf675fbdb
BLAKE2b-256 e261095cadf2a3f660ef344623e0c4cbb126da3390e04ed4b3c99c8c07fe1362

See more details on using hashes here.

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

Hashes for tempered-0.11.0-py3-none-any.whl
Algorithm Hash digest
SHA256 ec33e8055f4f6b40074790f3727411268ac87825fff3a50f4c00ab2127e556d7
MD5 6ed923dd1eecae8c302bb37514359f91
BLAKE2b-256 65a8e62a5c4d75be295dd1ee6b6d583c061f237a7289eeea81573047fc175975

See more details on using hashes here.

Supported by

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