Skip to main content

Component framework for Python

Project description

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.

Project details


Download files

Download the file for your platform. If you're not sure which to choose, learn more about installing packages.

Source Distribution

compone-0.4.1.tar.gz (27.0 kB view details)

Uploaded Source

Built Distribution

If you're not sure about the file name format, learn more about wheel file names.

compone-0.4.1-py3-none-any.whl (19.7 kB view details)

Uploaded Python 3

File details

Details for the file compone-0.4.1.tar.gz.

File metadata

  • Download URL: compone-0.4.1.tar.gz
  • Upload date:
  • Size: 27.0 kB
  • Tags: Source
  • Uploaded using Trusted Publishing? No
  • Uploaded via: uv/0.11.2 {"installer":{"name":"uv","version":"0.11.2","subcommand":["publish"]},"python":null,"implementation":{"name":null,"version":null},"distro":{"name":"NixOS","version":"26.05","id":"yarara","libc":null},"system":{"name":null,"release":null},"cpu":null,"openssl_version":null,"setuptools_version":null,"rustc_version":null,"ci":null}

File hashes

Hashes for compone-0.4.1.tar.gz
Algorithm Hash digest
SHA256 edd73d195ea6081650c984cd9f6461f8ff6ae8c49985a2ae0a25322b8e951252
MD5 e907f5e42f3b6a37ef3651ead9e81729
BLAKE2b-256 33e2f7da1572cf08e5a6ab79e500710d1399df9203439ca3583fc325f9fbdf77

See more details on using hashes here.

File details

Details for the file compone-0.4.1-py3-none-any.whl.

File metadata

  • Download URL: compone-0.4.1-py3-none-any.whl
  • Upload date:
  • Size: 19.7 kB
  • Tags: Python 3
  • Uploaded using Trusted Publishing? No
  • Uploaded via: uv/0.11.2 {"installer":{"name":"uv","version":"0.11.2","subcommand":["publish"]},"python":null,"implementation":{"name":null,"version":null},"distro":{"name":"NixOS","version":"26.05","id":"yarara","libc":null},"system":{"name":null,"release":null},"cpu":null,"openssl_version":null,"setuptools_version":null,"rustc_version":null,"ci":null}

File hashes

Hashes for compone-0.4.1-py3-none-any.whl
Algorithm Hash digest
SHA256 b1db163cdba3c27c3c61c96c00dc8f3d7f29d8d4aee1e0141995003d24523a0e
MD5 6e4b7316d28e4c2d7e0394b21a9fd133
BLAKE2b-256 ab5e8e23c5e2d70e3605e7cf8688e62853ea907016f349c3d1c46bb3b6c9793d

See more details on using hashes here.

Supported by

AWS Cloud computing and Security Sponsor Datadog Monitoring Depot Continuous Integration Fastly CDN Google Download Analytics Pingdom Monitoring Sentry Error logging StatusPage Status page