Ecosyste.ms: Awesome
An open API service indexing awesome lists of open source software.
https://github.com/jviide/htm.py
JSX-like syntax in plain Python
https://github.com/jviide/htm.py
jsx python python3 templating
Last synced: about 2 months ago
JSON representation
JSX-like syntax in plain Python
- Host: GitHub
- URL: https://github.com/jviide/htm.py
- Owner: jviide
- License: mit
- Archived: true
- Created: 2019-06-12T18:56:45.000Z (over 5 years ago)
- Default Branch: master
- Last Pushed: 2020-05-18T15:50:10.000Z (over 4 years ago)
- Last Synced: 2024-07-01T13:13:25.700Z (3 months ago)
- Topics: jsx, python, python3, templating
- Language: Python
- Homepage: https://jviide.github.io/htm.py
- Size: 5.62 MB
- Stars: 107
- Watchers: 4
- Forks: 6
- Open Issues: 2
-
Metadata Files:
- Readme: README.md
- License: LICENSE
Awesome Lists containing this project
README
# htm.py ![Tests](https://github.com/jviide/htm.py/workflows/Tests/badge.svg) [![PyPI](https://img.shields.io/pypi/v/htm.svg?color=blue)](https://pypi.org/project/htm/)
A Python version of [developit/htm](https://github.com/developit/htm) - JSX-like syntax in plain ~~JavaScript~~ Python.
![](https://user-images.githubusercontent.com/19776768/59420458-99d60000-8dd5-11e9-9d29-02fff6c83a55.png)
## Documentation
The main documentation of this module is located at https://jviide.github.io/htm.py/.
## Installation
```sh
$ pip3 install htm
```## Usage
```py
from htm import htm@htm
def html(tag, props, children):
return tag, props, childrena = 1
b = {"bar": 100}
c = "span"
d = "world"html("""
<{c}>Hello, {d}!/>
""")
# ('div', {'foo': 3, 'bar': 100}, [('span', {}, ['Hello,', 'world', '!'])])
```## Development
To install locally:
```shell script
$ pip install -e .
```If you want to run tests and build the Sphinx docs and their examples...that runs into [a problem with hyperpython's transitive dependencies](https://github.com/ejplatform/hyperpython/issues/4).
Thus:```shell script
$ pip install toolz
$ pip install sidekick
$ pip install -e .[docs]
```### Running Tests
```sh
$ python3 -m unittest discover -s tests
```### Building Docs
Documentation is available in the `docs` directory.
First install the dependencies then build the docs:```shell script
$ pip install -e .[docs]
$ cd docs
$ sphinx-build -b html . _build
```## License
This library is licensed under the MIT license. See [./LICENSE](./LICENSE).