Skip to content

kissgyorgy/compone

Folders and files

NameName
Last commit message
Last commit date

Latest commit

adf5e50 · Feb 19, 2025
Feb 2, 2025
Feb 14, 2025
Oct 27, 2024
Feb 2, 2025
Feb 2, 2025
Feb 19, 2025
Oct 12, 2024
Oct 27, 2024
Feb 2, 2025
Aug 10, 2023
Oct 27, 2024
Feb 14, 2025
Feb 2, 2025
Jan 26, 2025
Feb 2, 2025
Feb 14, 2025

Repository files navigation

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.Components 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

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"])
# <div><h1>Hello World!</h1>My Child</div>

This is a silly example, but for more examples and features, check out the Tutorial in the Documentation.

Installation

You can simply install the compone package from PyPI:

$ pip install compone

The only dependency is markupsafe for escaping HTML.

Documentation

The documentation is available at https://compone.kissgyorgy.me.