Skip to main content

HyperText with Python

Project description

Hyperscript

Hyperscript is a lightweight library that allows you to write HTML with Python. It is heavily inspired by HyperScript.

Example usage

>>> print(h("p", "Hello world!"))
<p>Hello world!</p>

Class and id selectors

>>> print(h("p.class1#id", "Hello world!"))
<p class="class1" id="id">Hello world!</p>

Style

>>> print(h("p", "Hello world!", {"style": {"color": "red"}}))
<p style="color: red">Hello world!</p>

Nesting elements

>>> print(h("div", h("p", "Hello world!")))
<div><p>Hello world!</p></div>

Attributes

>>> print(h("a", {"href": "https://www.example.com"}, "link"))
<a href="https://www.example.com">link</a>

Boolean attributes

>>> print(h("input", {"type": "checkbox", "checked": True}))  # Behavior is the same if "checked" is None
<input type="checkbox" checked>
>>> print(h("input", {"type": "checkbox", "checked": ""}))
<input type="checkbox" checked="">
>>> print(h("input", {"type": "checkbox", "checked": False}))
<input type="checkbox">

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

hyperscript-0.2.0.tar.gz (7.2 kB view details)

Uploaded Source

Built Distribution

hyperscript-0.2.0-py3-none-any.whl (4.7 kB view details)

Uploaded Python 3

File details

Details for the file hyperscript-0.2.0.tar.gz.

File metadata

  • Download URL: hyperscript-0.2.0.tar.gz
  • Upload date:
  • Size: 7.2 kB
  • Tags: Source
  • Uploaded using Trusted Publishing? Yes
  • Uploaded via: twine/5.1.1 CPython/3.12.6

File hashes

Hashes for hyperscript-0.2.0.tar.gz
Algorithm Hash digest
SHA256 86c858b69c736057dab624d00361398678e1e48d9855bc0a723ff2272e9d15a6
MD5 b1984d04df48ae9ef1466b63332a2010
BLAKE2b-256 7dbba98c5a09ba5b7a738dec1fcdda57cbe26fb842f27314c237d2c38db9d3d0

See more details on using hashes here.

File details

Details for the file hyperscript-0.2.0-py3-none-any.whl.

File metadata

  • Download URL: hyperscript-0.2.0-py3-none-any.whl
  • Upload date:
  • Size: 4.7 kB
  • Tags: Python 3
  • Uploaded using Trusted Publishing? Yes
  • Uploaded via: twine/5.1.1 CPython/3.12.6

File hashes

Hashes for hyperscript-0.2.0-py3-none-any.whl
Algorithm Hash digest
SHA256 3449ffafe217bc7cdd337824a755351cb7808b02dbce9a18dbe1355cbefd0c56
MD5 5532ec09ce02382802c106a9799865ed
BLAKE2b-256 f31f5f5e0ab0a0659f84fb4f50932084f8a885986006dc7709406bd480682963

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