https://github.com/dkter/html-witchcraft
not your typical python HTML generator
https://github.com/dkter/html-witchcraft
html python
Last synced: about 1 year ago
JSON representation
not your typical python HTML generator
- Host: GitHub
- URL: https://github.com/dkter/html-witchcraft
- Owner: dkter
- License: mpl-2.0
- Created: 2020-05-31T04:45:28.000Z (about 6 years ago)
- Default Branch: main
- Last Pushed: 2020-06-29T01:01:25.000Z (almost 6 years ago)
- Last Synced: 2025-03-27T18:52:45.265Z (about 1 year ago)
- Topics: html, python
- Language: Python
- Size: 16.6 KB
- Stars: 9
- Watchers: 2
- Forks: 1
- Open Issues: 0
-
Metadata Files:
- Readme: README.md
- License: LICENSE.txt
Awesome Lists containing this project
README
## html-witchcraft
### FAQ
#### What does it do?
See for yourself -
```python
from witchcraft import Page
class ExamplePage(Page):
def render(self):
return ...[
[html]
[head]
[title] ("My Cool Website") [-title]
[-head]
[body]
[marquee][h1] ("Wheeeeeeeeee") [-h1][-marquee]
[-body]
[-html]
]
page = ExamplePage()
print(page.render())
```
```
$ python test.py
My Cool Website
Wheeeeeeeeee
```
(see another example at [example.py](https://github.com/dkter/html-witchcraft/blob/main/example.py)!)
#### what the heck
I'm glad you enjoyed it.
#### Should I use this?
Probably not. This was mainly intended as a fun project and proof of concept to see the extent of what I could do with metaprogramming in Python. Most people probably don't know this is possible!
Obviously this doesn't have as many features as, say, [jinja2](https://palletsprojects.com/p/jinja/) or [dominate](https://github.com/Knio/dominate) and I haven't tried to break it at all so there may be vulnerabilities somewhere. It's just cool.
#### But how does it work?
I might post a full technical explanation later. In the meantime, have a look at [witchcraft.py](https://github.com/dkter/html-witchcraft/blob/main/witchcraft.py). It's pretty well documented.