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

there's a bit more code to it than this but you get the idea (the rest is on the github page)
18 Upvotes

9 comments sorted by

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 ...