Skip to main content

Write html components directly in python and you have a beautiful but controversial MIXTure

Project description

Write html components directly in python and you have a beautiful but controversial MIXTure.

Yes, controversial.

If you don’t like it, ignore it (but you can use this without the html-in-python part, see below ;))

Based on pyxl. Python 3.6+ only.

Usage

Let’s create a file example.py

# coding: mixt

from mixt import html, Element, Required

class Hello(Element):
    class PropTypes:
        name: Required[str]

    def render(self, context):
        return <div>Hello, {self.name}</div>

print(<Hello name="World"/>)

And execute it:

$ python example.py
<div>Hello, World</div>

If you don’t like to write html in python, you can still use it:

from mixt import html, Element, Required

class Hello(Element):
    class PropTypes:
        name: Required[str]

    def render(self, context):
        return html.Div()("Hello, ", self.name)

print(Hello(name="World"))

There is more. Doc will come soon, we are still in early alpha :)

Installation

Run these two commands. The second one will tell python how to understand files with html inside.

pip install mixt
mixt-post-install

To check that everything is ready, run:

python -m mixt.example

You should have this output:

<div title="Greeting">Hello, World</div>

If you don’t want to use the html-in-python stuff, don’t run mixt-post-install. And then test with (to have the same output):

python -m mixt.example_pure_python

Development

Clone the git project then:

make dev

To check that everything is ready, run:

python -m mixt.example

You should have this output:

<div title="Greeting">Hello, World</div>

After having done some code:

make tests
make lint

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

mixt-0.1.tar.gz (25.3 kB view details)

Uploaded Source

Built Distribution

mixt-0.1-py2.py3-none-any.whl (28.7 kB view details)

Uploaded Python 2 Python 3

File details

Details for the file mixt-0.1.tar.gz.

File metadata

  • Download URL: mixt-0.1.tar.gz
  • Upload date:
  • Size: 25.3 kB
  • Tags: Source
  • Uploaded using Trusted Publishing? No

File hashes

Hashes for mixt-0.1.tar.gz
Algorithm Hash digest
SHA256 c6aa3188ad4ed8b97c1af0e5857aedcfcdee767b33ed82b12448b9d7e896b4cb
MD5 d27b064332437ff99bfd3fb23f7f8fb2
BLAKE2b-256 d6331540fa8a50b9a69a89ad6e5ebf567644237bb59e71581ac1f16dba8a1a27

See more details on using hashes here.

File details

Details for the file mixt-0.1-py2.py3-none-any.whl.

File metadata

File hashes

Hashes for mixt-0.1-py2.py3-none-any.whl
Algorithm Hash digest
SHA256 73367cf4f3ebb9cc97707327da49612bfdfac4e9c485e78ad8135994587c7ff8
MD5 1b92fac53cbef8aa687a120cf6174a95
BLAKE2b-256 bf0ca3bbff3e90c4174d518f3b1d193ab5f47f6157b8b9856a9efd69aff645ef

See more details on using hashes here.

Supported by

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