Maler
A Python templating library for rendering dynamic HTML and MJML content in a type-safe way.
Why Maler?
"Maler" is Norwegian for both "painters" and "templates" — fitting for a library that helps you paint your pages with reusable templates.
Installation
uv add maler
Or with pip:
pip install maler
Quick Start
Create your first template:
from maler import div, span
my_page = div(
"Hello ", span("World", class_="font-bold")
).render()
Dynamic Content
Use the @template decorator for safe-dynamic content.
This will escape unsafe HTML content:
from maler import div, span, template
@template
def hello_world(name: str | None = None):
return div(
"Hello ", span(name or "World", class_="font-bold")
)
html = hello_world(name="<script>a_bad_script=...</script>")
Leading to the following:
<div>Hello <span class="font-bold"><script>a_bad_script...</span></div>
FastAPI Integration
Maler integrates seamlessly with FastAPI using the render_template decorator:
from fastapi import FastAPI
from maler import div, h1
from maler.fastapi import render_template
app = FastAPI()
def page_template(user: User):
return div(
h1("Welcome, ", user.name)
)
def error_template(error: Exception):
return div("Something went wrong!")
@app.get("/user/{user_id}")
@render_template(page_template, error_template)
async def get_user(user_id: int):
return await fetch_user(user_id)
The decorator automatically returns an HTMLResponse. If the client sends Accept-Encoding: application/json will it return JSON instead.
MJML Support
Create responsive emails using MJML syntax with the @mjml_template decorator:
from maler.mjml import mjml_template
from maler.mjml_tags import mjml, mj_body, mj_section, mj_column, mj_text
from maler import Tag
@mjml_template
def welcome_email(name: str):
return mjml(
mj_body(
mj_section(
mj_column(
mj_text(f"Welcome, {name}!")
)
)
)
)
html = welcome_email("Alice")
This requires the mrml package for MJML-to-HTML conversion.
Metadata
Release files for maler 0.1.1
For a detailed explanation of source distributions (sdists) and built distributions (wheels), please see the package formats documentation.
Source distribution (sdist)
| File | Size | Uploaded | Provenance | |
|---|---|---|---|---|
| maler-0.1.1.tar.gz | 10.5 kB | Without provenance | Details |
Built distribution (wheel)
| File | Interpreter | ABI | Platform | Reset |
|---|---|---|---|---|
| maler-0.1.1-py3-none-any.whl | Python 3 | none | any | Details |
Total release size: 23.4 kB
Release files / maler-0.1.1.tar.gz
| Download URL | maler-0.1.1.tar.gz |
|---|---|
| Size | 10.5 kB |
| Tags | Source |
|
SHA-256 checksum How to use checksums |
b53ae5806f950242490c9aa7d0cf6fc3d94a42b5f68bb48e659db13e7881c4d7
|
|
BLAKE2b-256 checksum How to use checksums |
8bc42c792d69484b8eb685b310a2fd069872ca95ac27016334d5390576e10bc8
|
| Upload date | |
|
Uploaded using Trusted Publishing? What is trusted publishing? |
No |
| Uploaded via |
uv/0.9.26 {"installer":{"name":"uv","version":"0.9.26","subcommand":["publish"]},"python":null,"implementation":{"name":null,"version":null},"distro":{"name":"Debian GNU/Linux","version":"13","id":"trixie","libc":null},"system":{"name":null,"release":null},"cpu":null,"openssl_version":null,"setuptools_version":null,"rustc_version":null,"ci":true}
|
Release files / maler-0.1.1-py3-none-any.whl
| Download URL | maler-0.1.1-py3-none-any.whl |
|---|---|
| Size | 12.9 kB |
| Tags | Python 3 |
|
SHA-256 checksum How to use checksums |
dedd9e0e2bcdebdeb4837cd41e0cad4de930ce6de5608b9812eb27ce46cb1c6f
|
|
BLAKE2b-256 checksum How to use checksums |
c49fb6919c05a61f093af3141b708d3fd641d001162c189b4350ddc57543b3d0
|
| Upload date | |
|
Uploaded using Trusted Publishing? What is trusted publishing? |
No |
| Uploaded via |
uv/0.9.26 {"installer":{"name":"uv","version":"0.9.26","subcommand":["publish"]},"python":null,"implementation":{"name":null,"version":null},"distro":{"name":"Debian GNU/Linux","version":"13","id":"trixie","libc":null},"system":{"name":null,"release":null},"cpu":null,"openssl_version":null,"setuptools_version":null,"rustc_version":null,"ci":true}
|
Security for maler 0.1.1
Provenance
Provenance describes where a file came from. On PyPI, provenance is shared via attestations, which provide a verifiable record of the build or publishing details. View details, limitations and caveats.
No provenance found
None of the files in this release were uploaded with provenance metadata.
A note on package security
PyPI is a repository for distributing packages, not a service for auditing them. While third-party security researchers and our staff do their best to detect and remove malicious packages, PyPI cannot guarantee the quality, security or suitability of any given package.
To learn more about protecting yourself from malicious actors, visit our package security documentation.