Skip to main content

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.

Metadata

Release files for neat-html 0.6.0

For a detailed explanation of source distributions (sdists) and built distributions (wheels), please see the package formats documentation.

Source distribution (sdist)

Source distribution for neat-html 0.6.0
File Size Uploaded Provenance
neat_html-0.6.0.tar.gz 5.8 kB Without provenance Details

Built distribution (wheel)

Table of built distributions (wheels) for neat-html 0.6.0
File Interpreter ABI Platform
neat_html-0.6.0-py3-none-any.whl Python 3 none any Details

Total release size: 13.1 kB

Release files / neat_html-0.6.0.tar.gz

Download URL neat_html-0.6.0.tar.gz
Size 5.8 kB
Tags Source
SHA-256 checksum
How to use checksums
20b3f3f6f2971928677dda829b2910f668fb8b5fb25b100602ff5d8e72b1ea7d
BLAKE2b-256 checksum
How to use checksums
a69b25035adb04b36a2fd004ea3fc8bd2f6c62dd7913d89174e5730db908d8a0
Upload date
Uploaded using Trusted Publishing?
What is trusted publishing?
No
Uploaded via poetry/1.8.3 CPython/3.12.4 Linux/6.9.5-1-MANJARO

Release files / neat_html-0.6.0-py3-none-any.whl

Download URL neat_html-0.6.0-py3-none-any.whl
Size 7.3 kB
Tags Python 3
SHA-256 checksum
How to use checksums
46415282a6eb8f08d92ac5a3cb4af0e445655b015bd80c9ec5790273d40b9558
BLAKE2b-256 checksum
How to use checksums
84271b235fb14471034f52a2ba3ade6d5baf74d52f0c818eb274773fea585638
Upload date
Uploaded using Trusted Publishing?
What is trusted publishing?
No
Uploaded via poetry/1.8.3 CPython/3.12.4 Linux/6.9.5-1-MANJARO

Security for neat-html 0.6.0

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.

Anthropic, PBC Visionary sponsor Bloomberg Visionary sponsor Hudson River Trading Visionary sponsor Meta Visionary sponsor NVIDIA Visionary sponsor Microsoft Sustainability sponsor Depot Continuous Integration AWS Cloud computing and Security Sponsor Datadog Monitoring Fastly CDN Google Download Analytics Sentry Error logging StatusPage Status page