Simple HTML Generation
Project description
minihtml - Simple HTML Generation
minihtml is a library to generate HTML documents from Python. It aims to provide an API that allows you to define the structure of an HTML document in a succinct and natural way.
By building up nested HTML elements using context managers, you can combine HTML generation with control flow statements in a way that is easy to read and does not obscure the structure of the resulting HTML document.
Installation
Install the minihtml package from PyPI:
pip install minihtml
or
uv add minihtml
Example
A basic "hello, world" example:
>>> from minihtml.tags import html, head, title, body, div, p, a, img
>>> with html(lang="en") as elem:
... with head:
... title("hello, world!")
... with body, div["#content main"]:
... p("Welcome to ", a(href="https://example.com/")("my website"))
... img(src="hello.png", alt="hello")
...
<...>
>>> print(elem)
<html lang="en">
<head>
<title>hello, world!</title>
</head>
<body>
<div id="content" class="main">
<p>Welcome to <a href="https://example.com/">my website</a></p>
<img src="hello.png" alt="hello">
</div>
</body>
</html>
Links
License
Minihtml is released under the MIT license. See LICENSE for more information.
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
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
File details
Details for the file minihtml-0.2.3.tar.gz.
File metadata
- Download URL: minihtml-0.2.3.tar.gz
- Upload date:
- Size: 940.9 kB
- Tags: Source
- Uploaded using Trusted Publishing? No
- Uploaded via: uv/0.6.12
File hashes
| Algorithm | Hash digest | |
|---|---|---|
| SHA256 |
2c7419de9ffcd63f155b279c386129db71d4d2aa9df8ed8a49f61e8871eb6f99
|
|
| MD5 |
9b8d1dd13e6cdbb9cccedd4156bb133e
|
|
| BLAKE2b-256 |
baf63f246f9bd90ee32774fa2fed9d4411382f6252d53842158cddf2a8a51fb1
|
File details
Details for the file minihtml-0.2.3-py3-none-any.whl.
File metadata
- Download URL: minihtml-0.2.3-py3-none-any.whl
- Upload date:
- Size: 13.1 kB
- Tags: Python 3
- Uploaded using Trusted Publishing? No
- Uploaded via: uv/0.6.12
File hashes
| Algorithm | Hash digest | |
|---|---|---|
| SHA256 |
3ecf34672fbd22ace997ed2a1806b6b295c0b88757c7f8edf4e7695b66e0a0c8
|
|
| MD5 |
f6ad779311d32f4062b714bc5ffb1136
|
|
| BLAKE2b-256 |
a64c85b4ec3f1a2122981b07dbbb6916e87be6254f49ee587f03b50308bf3d70
|