Skip to main content

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 details)

Uploaded Source

Built Distribution

neat_html-0.6.0-py3-none-any.whl (7.3 kB view details)

Uploaded Python 3

File details

Details for the file neat_html-0.6.0.tar.gz.

File metadata

  • Download URL: neat_html-0.6.0.tar.gz
  • Upload date:
  • Size: 5.8 kB
  • Tags: Source
  • Uploaded using Trusted Publishing? No
  • Uploaded via: poetry/1.8.3 CPython/3.12.4 Linux/6.9.5-1-MANJARO

File hashes

Hashes for neat_html-0.6.0.tar.gz
Algorithm Hash digest
SHA256 20b3f3f6f2971928677dda829b2910f668fb8b5fb25b100602ff5d8e72b1ea7d
MD5 00844ed97c75f6f4a0de6a5908e2794c
BLAKE2b-256 a69b25035adb04b36a2fd004ea3fc8bd2f6c62dd7913d89174e5730db908d8a0

See more details on using hashes here.

File details

Details for the file neat_html-0.6.0-py3-none-any.whl.

File metadata

  • Download URL: neat_html-0.6.0-py3-none-any.whl
  • Upload date:
  • Size: 7.3 kB
  • Tags: Python 3
  • Uploaded using Trusted Publishing? No
  • Uploaded via: poetry/1.8.3 CPython/3.12.4 Linux/6.9.5-1-MANJARO

File hashes

Hashes for neat_html-0.6.0-py3-none-any.whl
Algorithm Hash digest
SHA256 46415282a6eb8f08d92ac5a3cb4af0e445655b015bd80c9ec5790273d40b9558
MD5 4060c4f71b7ceb6b12b12338969a087c
BLAKE2b-256 84271b235fb14471034f52a2ba3ade6d5baf74d52f0c818eb274773fea585638

See more details on using hashes here.

Supported by

AWS AWS Cloud computing and Security Sponsor Datadog Datadog Monitoring Fastly Fastly CDN Google Google Download Analytics Microsoft Microsoft PSF Sponsor Pingdom Pingdom Monitoring Sentry Sentry Error logging StatusPage StatusPage Status page