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 library

Usage:

from yahb 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.3.0.tar.gz (13.2 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.3.0-py3-none-any.whl (11.5 kB view details)

Uploaded Python 3

File details

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

File metadata

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

File hashes

Hashes for yahb-0.3.0.tar.gz
Algorithm Hash digest
SHA256 5199decb19ff1b715b2df6c37fe95d435c0161be9ffa92b24a4afada77fff246
MD5 365be7e6f73a790872c8ae3c2ed56eb1
BLAKE2b-256 20b2cc64ce8506b13430f153ecee3d24fcf7335c5a61863a9fd36694294f37cc

See more details on using hashes here.

File details

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

File metadata

  • Download URL: yahb-0.3.0-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.3.0-py3-none-any.whl
Algorithm Hash digest
SHA256 ec46aea9d42d80a8e2a20b86f07e631687c8962c8b48bc87c0fb696aa4c58366
MD5 5cd1730a5245bd5508d056ec929cdda9
BLAKE2b-256 6cdfbccf8b25fbd8d5eb5a09c8cce74c660802bd821df913b6956161bf2d3560

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