Ecosyste.ms: Awesome
An open API service indexing awesome lists of open source software.
https://github.com/kissgyorgy/compone
Component framework for Python
https://github.com/kissgyorgy/compone
Last synced: 29 days ago
JSON representation
Component framework for Python
- Host: GitHub
- URL: https://github.com/kissgyorgy/compone
- Owner: kissgyorgy
- License: mit
- Created: 2023-08-10T07:43:51.000Z (over 1 year ago)
- Default Branch: master
- Last Pushed: 2024-04-12T13:45:00.000Z (8 months ago)
- Last Synced: 2024-04-12T20:49:18.592Z (8 months ago)
- Language: Python
- Homepage:
- Size: 215 KB
- Stars: 2
- Watchers: 2
- Forks: 0
- Open Issues: 8
-
Metadata Files:
- Readme: README.md
- License: LICENSE
Awesome Lists containing this project
README
# Compone for Python
**Compone** is a Python **component framework** which makes it possible to
**generate HTML, XML**, RSS and other markup formats using type-safe
**Python objects** with a very simple API.`compone.Component`s are **fully-reusable** Python classes in
**ANY Python web framework** or project out-of-the-box without extra code needed.It's a modern **alternative to template engines** like Jinja2 or Django
templates for generating strings.## Hello World
```python
from compone import Component, html@Component
def Hello(name: str, children):
return html.Div[
html.H1[f"Hello {name}!"],
children,
]print(Hello("World")["My Child"])
#Hello World!
My Child
```This is a silly example, but for more examples and features, check out the
[Tutorial](https://compone.kissgyorgy.me/tutorial/) in the Documentation.## Installation
You can simply install the [`compone` package](https://pypi.org/project/compone/) from PyPI:
```bash
$ pip install compone
```The only dependency is [markupsafe](https://pypi.org/project/MarkupSafe/) for escaping HTML.
## Documentation
The documentation is available at
[https://compone.kissgyorgy.me](https://compone.kissgyorgy.me/).