Skip to main content

HTML Elements

HTML Elements allows you to write HTML website while staying completely in Python. This will allow you to create SPA-like components, but keep your presentation layer in Python.

Because it is in pure Python, it allows to use all the Python goodies such as functions, linting, type checking.

Check out the complete documentation here

Example

To create this form (made with Bulma)

<form>
  <div class="field">
    <label class="label">
      Name
    </label>
    <div class="control">
      <input class="input" name="name" placeholder="Name" type="text" />
    </div>
  </div>
  <div class="field">
    <label class="label">
      Email
    </label>
    <div class="control">
      <input class="input" name="email" placeholder="Email" type="email" />
    </div>
  </div>
  <button class="button" type="submit">
    Submit
  </button>
</form>

You write

from html_elements import elements as e


def Input(type: str, label: str) -> e.BaseHtmlElement:
    display = label.title()
    return e.Div(
        [
            e.Label([display], classes=["label"]),
            e.Div(
                [e.Input(classes=["input"], type=type, placeholder=display, name=label)],
                classes=["control"]
            )
        ],
        classes=["field"]
    )

html = e.Form([
    Input("text", "name"),
    Input("email", "email"),
    e.Button(["Submit"], classes=["button"], type="submit")
])

raw = html.to_html(indent_step=2)

Metadata

Release files for html-elements 0.2.1

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

Source distribution (sdist)

Source distribution for html-elements 0.2.1
File Size Uploaded Provenance Actions
html_elements-0.2.1.tar.gz 11.8 kB Without provenance Details for html_elements-0.2.1.tar.gz

Built distribution (wheel)

Table of built distributions (wheels) for html-elements 0.2.1
File Interpreter ABI Platform Actions
html_elements-0.2.1-py3-none-any.whl Python 3 none any Details for html_elements-0.2.1-py3-none-any.whl

Total release size: 24.0 kB

Release files / html_elements-0.2.1.tar.gz

Download URL html_elements-0.2.1.tar.gz
Size 11.8 kB
Tags Source
SHA-256 checksum
How to use checksums
d85b97fcadb35c7f388e366dc6564bb5e4572c8f647423a0d55afcdf62d645ce
BLAKE2b-256 checksum
How to use checksums
24c7eb752c16ef9eeb7c6dd88b1b344e068d319fdbce3cff6becec9750a4b6dc
Upload date
Uploaded using Trusted Publishing?
What is trusted publishing?
No
Uploaded via poetry/1.8.2 CPython/3.10.5 Darwin/23.5.0

Release files / html_elements-0.2.1-py3-none-any.whl

Download URL html_elements-0.2.1-py3-none-any.whl
Size 12.2 kB
Tags Python 3
SHA-256 checksum
How to use checksums
33ec27ff2ce3c8eb99b908b31fac44f60b0cc4becb13e922e5af5e94a0a69329
BLAKE2b-256 checksum
How to use checksums
2e9deb7d2b6afc75226bdb6cb773a99d8183c6c18824b6186d7c4866e42c0ef9
Upload date
Uploaded using Trusted Publishing?
What is trusted publishing?
No
Uploaded via poetry/1.8.2 CPython/3.10.5 Darwin/23.5.0

Security for html-elements 0.2.1

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.

To learn more about protecting yourself from malicious actors, visit our package security documentation.

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