hyperscript-0.3.0
توضیحات
HyperText with Python
| ویژگی | مقدار |
|---|---|
| سیستم عامل | OS Independent |
| نام فایل | hyperscript-0.3.0 |
| نام | hyperscript |
| نسخه کتابخانه | 0.3.0 |
| نگهدارنده | [] |
| ایمیل نگهدارنده | [] |
| نویسنده | - |
| ایمیل نویسنده | Vincent Chan <vincent@qualdata.io> |
| آدرس صفحه اصلی | - |
| آدرس اینترنتی | https://pypi.org/project/hyperscript/ |
| مجوز | MIT License |
# 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!"))
<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">
```
Filtering out empty elements
```
>>> print(h("div", h("p", "Hello"), h("div", ""), h("p", "world!")))
<div><p>Hello</p><div></div><p>world!</p></div>
>>> print(h("div", h("p", "Hello"), h("div", ""), h("p", "world!"), remove_empty=True))
<div><p>Hello</p><p>world!</p></div>
```
نیازمندی
| مقدار | نام |
|---|---|
| xtr | pre-commit; |
زبان مورد نیاز
| مقدار | نام |
|---|---|
| >=3.8 | Python |
نحوه نصب
نصب پکیج whl hyperscript-0.3.0:
pip install hyperscript-0.3.0.whl
نصب پکیج tar.gz hyperscript-0.3.0:
pip install hyperscript-0.3.0.tar.gz