A python library for writing and composing HTML.
Project description
neat-html
A python library for writing and composing HTML.
Features:
- small API to learn
- fully typed API (strict mypy)
- produces "neatly" formatted HTML
- written in pure python
- zero dependencies
- comprehensive test suite (100% coverage)
- no recursion
Example
Code:
from neat_html import h, render
greeting = h("strong", {"style": {"color": "green"}}, "Hello")
html = h("p", {"id": "foo"}, [greeting, ", World!"])
print(render(html))
Output:
<p id="foo">
<strong style="color: green">Hello</strong>, World!
</p>
Installation
Using pip:
pip install neat-html
Using poetry:
poetry add neat-html
Using uv:
uv pip install neat-html
User guide
Basics
from neat_html import Element, h, render
# define an element
button: Element = h("button", "Submit")
# render the element to html
html: str = render(button)
Integrations
Django
django-neat-html
https://github.com/SamDudley/django-neat-html
A work in progress library that integrates neat-html into Django as a template backend.
API
I would recommend taking a look at the source code for the details of the API.
The best place to start would be in neat_html/__init__.py.
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
neat_html-0.6.0.tar.gz
(5.8 kB
view hashes)
Built Distribution
Close
Hashes for neat_html-0.6.0-py3-none-any.whl
Algorithm | Hash digest | |
---|---|---|
SHA256 | 46415282a6eb8f08d92ac5a3cb4af0e445655b015bd80c9ec5790273d40b9558 |
|
MD5 | 4060c4f71b7ceb6b12b12338969a087c |
|
BLAKE2b-256 | 84271b235fb14471034f52a2ba3ade6d5baf74d52f0c818eb274773fea585638 |