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
Release history Release notifications | RSS feed
Download files
Download the file for your platform. If you're not sure which to choose, learn more about installing packages.