Ecosyste.ms: Awesome

An open API service indexing awesome lists of open source software.

Awesome Lists | Featured Topics | Projects

https://github.com/vchan/hyperscript

HyperText with Python
https://github.com/vchan/hyperscript

Last synced: 5 days ago
JSON representation

HyperText with Python

Awesome Lists containing this project

README

        

# Hyperscript
Hyperscript is a lightweight library that allows you to write HTML with Python. It is heavily inspired by [HyperScript](https://github.com/hyperhype/hyperscript).

## Example usage
```
>>> print(h("p", "Hello world!"))

Hello world!


```
Class and id selectors
```
>>> print(h("p.class1#id", "Hello world!"))

Hello world!


```
Style
```
>>> print(h("p", "Hello world!", {"style": {"color": "red"}}))

Hello world!


```
Nesting elements
```
>>> print(h("div", h("p", "Hello world!")))

Hello world!


```
Attributes
```
>>> print(h("a", {"href": "https://www.example.com"}, "link"))
link
```
Boolean attributes
```
>>> print(h("input", {"type": "checkbox", "checked": True})) # Behavior is the same if "checked" is None

>>> print(h("input", {"type": "checkbox", "checked": ""}))

>>> print(h("input", {"type": "checkbox", "checked": False}))

```