r/PyScript • • Jul 17 '22
Pure Python - No HTML
It's a dream of mine to be able to code pure Python in the web browser, and I realized that PyScript allows me to do that. I've created a fork of PyScript here where I've added some Python functions that create HTML elements so you don't have to:
https://github.com/coryfitz/pydesyn
Let me know what you think! It's very much a work in progress


18
Upvotes
View all comments
Show parent comment
1
u/manatlan Jul 19 '22
just my 2 cents ....
for crafting html tags ... you should adopt a domonic/brython style, which is more like :
<html_tag>( content, _class="", _id="", _value="", ... )
where "content" can be an object or a list of objects, or None .... to populate its innerHTML (childs). Attributs prefixed with "_" is a really good practice ...
so all your constructor will remain the same base
a("hello",_href="http://link")
body( content )
input( _value="my value" , _name="my_field")
etc ...