Giter VIP home page Giter VIP logo

neat-html's Introduction

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.

neat-html's People

Contributors

samdudley avatar

Stargazers

 avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar

Watchers

 avatar

neat-html's Issues

Improve types

  • remove all Any uses
  • fix h signature to be superset of all overloaded signatures

Add type annotations

I want to add type annotations across the whole project. Let's start at the deep end and apply mypy in strict mode.

Recommend Projects

  • React photo React

    A declarative, efficient, and flexible JavaScript library for building user interfaces.

  • Vue.js photo Vue.js

    ๐Ÿ–– Vue.js is a progressive, incrementally-adoptable JavaScript framework for building UI on the web.

  • Typescript photo Typescript

    TypeScript is a superset of JavaScript that compiles to clean JavaScript output.

  • TensorFlow photo TensorFlow

    An Open Source Machine Learning Framework for Everyone

  • Django photo Django

    The Web framework for perfectionists with deadlines.

  • D3 photo D3

    Bring data to life with SVG, Canvas and HTML. ๐Ÿ“Š๐Ÿ“ˆ๐ŸŽ‰

Recommend Topics

  • javascript

    JavaScript (JS) is a lightweight interpreted programming language with first-class functions.

  • web

    Some thing interesting about web. New door for the world.

  • server

    A server is a program made to process requests and deliver data to clients.

  • Machine learning

    Machine learning is a way of modeling and interpreting data that allows a piece of software to respond intelligently.

  • Game

    Some thing interesting about game, make everyone happy.

Recommend Org

  • Facebook photo Facebook

    We are working to build community through open source technology. NB: members must have two-factor auth.

  • Microsoft photo Microsoft

    Open source projects and samples from Microsoft.

  • Google photo Google

    Google โค๏ธ Open Source for everyone.

  • D3 photo D3

    Data-Driven Documents codes.