Python in, HTML out.
Project description
htmlclasses
Python in, HTML out.
There are templating engines making it possible to write code in HTML template files. However, I would very much prefer to be able to write Python that gets converted to HTML rather than write Python-like mini language engulfed in HTML.
Version
0.2.1
Goals
Generating valid HTML from pure Python code.
Non-goals
Features geared toward JavaScript.
- I find using 2 intertwined languages too cumbersome.
- JavaScript is heavily overused and misused. I don't want to add to the problem.
Installation
pip install htmlclasses
Developing
This project is managed with poetry: https://github.com/python-poetry/poetry
git clone git@github.com:uigctaw/htmlclasses.git
poetry install
Running tests
./check_all.sh
Examples
To convert Python to HTML run:
from htmlclasses import to_string
to_string(html(), indent=' ')
Hello World
from htmlclasses import E
class html(E):
class head:
pass
class body:
class p:
TEXT = 'Hello, world!'
<!DOCTYPE html>
<html>
<head/>
<body>
<p>Hello, world!</p>
</body>
</html>
Alternatives
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
htmlclasses-0.2.1.tar.gz
(4.5 kB
view hashes)
Built Distribution
Close
Hashes for htmlclasses-0.2.1-py3-none-any.whl
Algorithm | Hash digest | |
---|---|---|
SHA256 | b6854529c627866f0e97bd1cc3afce6451c73db0a6c94a4f5d5a21da65a61e72 |
|
MD5 | df32d4e010e0fb3bb2312d9c8d8011c2 |
|
BLAKE2b-256 | 549c4938b9ef31f64326b527bc3647895631f1ddb6ffa85e64b7bf264225b069 |