Skip to main content

Yet another Python HTML builder

Project description

Yet Another Python HTML Builder

A single-file, zero-dependency, fully-typed HTML builder

Usage:

from htmlbuilder import (
    Document,
    Element,
    body,
    h1,
    head,
    html,
    img,
    link,
    main,
    meta,
    p,
    title,
)


def app() -> Element:
    return main(
        h1("Welcome to HTML Builder"),
        p(
            "Here's a cat for you:",
            img(src="https://cataas.com/cat"),
        ),
    )


doc = Document(
    html(
        head(
            meta(charset="UTF-8"),
            meta(name="viewport", content="width=device-width, initial-scale=1.0"),
            title("My Awesome Page"),
            link(rel="stylesheet", href="https://cdn.simplecss.org/simple.css"),
        ),
        body(app()),
        lang="en",
    )
)
print(doc)

Output:

<!DOCTYPE html>
<html lang="en">
  <head>
    <meta charset="UTF-8"/>
    <meta name="viewport" content="width=device-width, initial-scale=1.0"/>
    <title>
      My Awesome Page
    </title>
    <link rel="stylesheet" href="https://cdn.simplecss.org/simple.css"/>
  </head>
  <body>
    <main>
      <h1>
        Welcome to HTML Builder
      </h1>
      <p>
        Here&#x27;s a cat for you:
        <img src="https://cataas.com/cat"/>
      </p>
    </main>
  </body>
</html>

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

yahb-0.2.1.tar.gz (14.0 kB view details)

Uploaded Source

Built Distribution

If you're not sure about the file name format, learn more about wheel file names.

yahb-0.2.1-py3-none-any.whl (11.5 kB view details)

Uploaded Python 3

File details

Details for the file yahb-0.2.1.tar.gz.

File metadata

  • Download URL: yahb-0.2.1.tar.gz
  • Upload date:
  • Size: 14.0 kB
  • Tags: Source
  • Uploaded using Trusted Publishing? Yes
  • Uploaded via: uv/0.8.11

File hashes

Hashes for yahb-0.2.1.tar.gz
Algorithm Hash digest
SHA256 990d64430d0731875a452b256075510aadcba4a281800010a846e5a7e9f3bb19
MD5 ddf3d2bcb0f7e6ae8dbd2b6557420fd8
BLAKE2b-256 505a49aa51fa444fdc808e522f2953206c2a3644d0ef3be286d7b6fbba32a311

See more details on using hashes here.

File details

Details for the file yahb-0.2.1-py3-none-any.whl.

File metadata

  • Download URL: yahb-0.2.1-py3-none-any.whl
  • Upload date:
  • Size: 11.5 kB
  • Tags: Python 3
  • Uploaded using Trusted Publishing? Yes
  • Uploaded via: uv/0.8.11

File hashes

Hashes for yahb-0.2.1-py3-none-any.whl
Algorithm Hash digest
SHA256 20adde5d536f6ce9e0b9b0f0ee5da4b8fbfdafb9aef81e4650f2b5a4bac621bc
MD5 1ee1f56c303f276d351fd289298622b5
BLAKE2b-256 a8751b209ad6e0e5bea5436d4006dce30dfb7e3df525bc0b39861ef15293a542

See more details on using hashes here.

Supported by

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