without-html
HTML as immutable Python values. Build a node tree with plain function calls,
render it to a string with a pure function. No template language, no loader
search path, no ambient application object, and no dependency on anything else in
the workspace: this is a value library that happens to be useful next to
without-web.
from without_asgi import Response, html_content
from without_html import render, table, tbody, td, th, thead, tr
def runs_table(runs): # a component is a function that returns a node
return table(
cls=["table", "table-striped"],
children=[
thead(children=tr(children=[th(children="run"), th(children="status")])),
tbody(children=(run_row(run) for run in runs)),
],
)
def run_row(run):
return tr(attrs={"id": f"run-{run.id}"}, children=[td(children=run.id), td(children=run.status)])
Response.from_content(200, html_content(render(runs_table(runs))))
Escaping is a type rather than a setting: text is escaped on the way in, and
Markup (MarkupSafe's own, kept under its own name, so anything Jinja or tdom
produced is already one) is the only thing that renders verbatim. The element
constructors carry HTML's own constraints in their signatures, so a void element
with children and an unescaped <script> body are type errors rather than runtime
surprises.
render returns the whole string; render_chunks walks the same tree and yields
the same bytes a chunk at a time, so a large page starts reaching a client while
the rest of it is still being built.
The tree is the interface, not the string: a component can be rendered whole for a page or on its own for a fragment, and syntax sugar can be layered on later without changing anything written against it.
See the
without-html guide
(with the API reference)
for nodes and escaping, the attribute rules, custom elements, and what this
deliberately does not do.
Metadata
Release files for without-html 0.0.6
For a detailed explanation of source distributions (sdists) and built distributions (wheels), please see the package formats documentation.
Source distribution (sdist)
| File | Size | Uploaded | |
|---|---|---|---|
| without_html-0.0.6.tar.gz | 19.4 kB | Details |
Built distribution (wheel)
| File | Interpreter | ABI | Platform | Reset |
|---|---|---|---|---|
| without_html-0.0.6-py3-none-any.whl | Python 3 | none | any | Details |
Total release size: 41.1 kB
Release files / without_html-0.0.6.tar.gz
| Download URL | without_html-0.0.6.tar.gz |
|---|---|
| Size | 19.4 kB |
| Tags | Source |
|
SHA-256 checksum How to use checksums |
322083cdc97e8cccc7c8b7cedaa6389d5b23da4ff7c8d73d68a937652db20c1f
|
|
BLAKE2b-256 checksum How to use checksums |
28c18ecb613d0c434a4a1d8219f70d2eae26246a10be5c79c7c727e9f2630915
|
| Upload date | |
|
Uploaded using Trusted Publishing? What is trusted publishing? |
Yes |
| Uploaded via |
uv/0.12.6 {"installer":{"name":"uv","version":"0.12.6","subcommand":["publish"]},"python":null,"implementation":{"name":null,"version":null},"distro":{"name":"Ubuntu","version":"24.04","id":"noble","libc":null},"system":{"name":null,"release":null},"cpu":null,"openssl_version":null,"setuptools_version":null,"rustc_version":null,"ci":true}
|
Release files / without_html-0.0.6-py3-none-any.whl
| Download URL | without_html-0.0.6-py3-none-any.whl |
|---|---|
| Size | 21.7 kB |
| Tags | Python 3 |
|
SHA-256 checksum How to use checksums |
60628244aa78b90c5d6e96f722e3be1dcec7da2915e3face36a4794937d96310
|
|
BLAKE2b-256 checksum How to use checksums |
a76b33767fa85962296ea9d2b5b55f1c6f4836c426f1743f0a050313a4a4caf0
|
| Upload date | |
|
Uploaded using Trusted Publishing? What is trusted publishing? |
Yes |
| Uploaded via |
uv/0.12.6 {"installer":{"name":"uv","version":"0.12.6","subcommand":["publish"]},"python":null,"implementation":{"name":null,"version":null},"distro":{"name":"Ubuntu","version":"24.04","id":"noble","libc":null},"system":{"name":null,"release":null},"cpu":null,"openssl_version":null,"setuptools_version":null,"rustc_version":null,"ci":true}
|