Ecosyste.ms: Awesome
An open API service indexing awesome lists of open source software.
https://github.com/keller-mark/with-html
(Ab)use python context managers to construct HTML
https://github.com/keller-mark/with-html
Last synced: 12 days ago
JSON representation
(Ab)use python context managers to construct HTML
- Host: GitHub
- URL: https://github.com/keller-mark/with-html
- Owner: keller-mark
- License: mit
- Created: 2024-08-07T12:35:18.000Z (6 months ago)
- Default Branch: main
- Last Pushed: 2024-08-09T01:37:06.000Z (6 months ago)
- Last Synced: 2024-11-13T06:21:41.777Z (2 months ago)
- Language: Python
- Homepage:
- Size: 14.6 KB
- Stars: 0
- Watchers: 1
- Forks: 0
- Open Issues: 6
-
Metadata Files:
- Readme: README.md
- License: LICENSE
Awesome Lists containing this project
README
# with-html
(Ab)use python context managers to construct HTML. Render the resulting tree using [anywidget](https://anywidget.dev).
:warning: This is an experiment
## Usage
```python
from with_html import create_root, RootWidgeth = create_root()
def my_button(h):
h.button("submit")with h.div():
h.h1("Test")
h.img(src="https://example.com/my_image.jpg", width=200, height=200)
h.p("my paragraph")
h(my_button)
h.p("another paragraph")
with h.table(style=dict(border="1px solid red")):
with h.tr():
h.th("Column 1")
h.th("Column 2")
with h.tr():
h.td("Value 1")
h.td("Value 2")w = RootWidget(h.root)
w
```## Development
```sh
conda create -n with-html python=3.12
conda activate with-html
pip install -e ".[dev]"
``````sh
jupyter lab
```