htag is my personnal project, and it won't exist if I never met
brython before. (quickly : it try to do the same, but on serverside, with pure python3)
it works perfectly in a pyscript/html page too (on client side). But I'd like to make it work in a brython html page too ! (new challenge!)
For that, I need to implement my "Tag constructor", which is a mix of brython `html.<tagName>()` and
domonic one. (which is able to set a lot of things at construction time)
Examples:
Tag.button("hello", _onclick = mymethod )
will produce html : <button onclick="...">hello</button>
"button" here, is an html tag name, and can be whatever imaginable
if you got web components (like
shoelace, for example)
Tag.sl_button("hello", _onclick = mymethod )
will produce html : <sl-button onclick="...">hello</sl-button>
to be short:
- the first parameter is the content of the node (everything that is str'able, or list)
- the kargs are specials :
- if it starts with "_" (domonic idea) : it's an html attributs (ex: _class,)
- if not : it sets a python property on the instance
- and if it starts with "_on" : it's a bindable method for the event
And it returns an brython HTMLElement, which can be attached in the dom
Here is a real example (use show source to see the short implem to do that)
it works great ^^
But I'd like to inherit HTMLElement, to be able to do more things ... and to be able to compose Tag (like in htag, to be able to create more complex Tag (the main goal of htag)) .... (i dream to be able to create components which will work "as is" in htag or in brython)
Can someone give me the direction/pointer to surcharge "HTMLElement" ... or at least, is it possible ?
thanks in advance
marc