Yet another Python HTML builder
Project description
Yet Another Python HTML Builder
A single-file, zero-dependency, fully-typed HTML builder
Usage:
from htmlbuilder import (
Document,
Element,
body,
h1,
head,
html,
img,
link,
main,
meta,
p,
title,
)
def app() -> Element:
return main(
h1("Welcome to HTML Builder"),
p(
"Here's a cat for you:",
img(src="https://cataas.com/cat"),
),
)
doc = Document(
html(
head(
meta(charset="UTF-8"),
meta(name="viewport", content="width=device-width, initial-scale=1.0"),
title("My Awesome Page"),
link(rel="stylesheet", href="https://cdn.simplecss.org/simple.css"),
),
body(app()),
lang="en",
)
)
print(doc)
Output:
<!DOCTYPE html>
<html lang="en">
<head>
<meta charset="UTF-8"/>
<meta name="viewport" content="width=device-width, initial-scale=1.0"/>
<title>
My Awesome Page
</title>
<link rel="stylesheet" href="https://cdn.simplecss.org/simple.css"/>
</head>
<body>
<main>
<h1>
Welcome to HTML Builder
</h1>
<p>
Here's a cat for you:
<img src="https://cataas.com/cat"/>
</p>
</main>
</body>
</html>
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
yahb-0.1.0.tar.gz
(14.0 kB
view details)
Built Distribution
Filter files by name, interpreter, ABI, and platform.
If you're not sure about the file name format, learn more about wheel file names.
Copy a direct link to the current filters
yahb-0.1.0-py3-none-any.whl
(11.5 kB
view details)
File details
Details for the file yahb-0.1.0.tar.gz.
File metadata
- Download URL: yahb-0.1.0.tar.gz
- Upload date:
- Size: 14.0 kB
- Tags: Source
- Uploaded using Trusted Publishing? No
- Uploaded via: uv/0.8.6
File hashes
| Algorithm | Hash digest | |
|---|---|---|
| SHA256 |
b9b5116bafbd35cf9183dedf095414adf74919a37c3913869d122b3524eb6a62
|
|
| MD5 |
365afce14cbed54046d613bcfefcd078
|
|
| BLAKE2b-256 |
c5dd03b752acd3f3c4d5ef34b2baa4d77e2af89c4f83687c20f68d1d640d1e10
|
File details
Details for the file yahb-0.1.0-py3-none-any.whl.
File metadata
- Download URL: yahb-0.1.0-py3-none-any.whl
- Upload date:
- Size: 11.5 kB
- Tags: Python 3
- Uploaded using Trusted Publishing? No
- Uploaded via: uv/0.8.6
File hashes
| Algorithm | Hash digest | |
|---|---|---|
| SHA256 |
35b78043104441d1f298236a1d2a7a2c8e5db55e66ed808c25536a61ac048716
|
|
| MD5 |
b55f421f222133cfaa3550c65474eb55
|
|
| BLAKE2b-256 |
2050b67b37ca9214fd400462393b7141ec4a950e671e1a2cefe45b46d70fc365
|