init
This commit is contained in:
commit
d90686c5d5
28
pyx.py
Normal file
28
pyx.py
Normal file
@ -0,0 +1,28 @@
|
||||
|
||||
|
||||
def html_args(dict):
|
||||
return " "+(" ".join([f'{key}="{value}"' for key, value in dict.items()])) if dict else ""
|
||||
|
||||
def html_element(tagName, children, args):
|
||||
return f"<{tagName}{html_args(args)}>{"".join(children)}</{tagName}>"
|
||||
|
||||
def html_element_self_closing(tagName, **args):
|
||||
return f"<{tagName}{html_args(args)} />"
|
||||
|
||||
def _H(tagName, *children, **attrs):
|
||||
childrenInvoker = lambda *childrenFinal: html_element(tagName, childrenFinal, attrs)
|
||||
return childrenInvoker if attrs else childrenInvoker(*children)
|
||||
|
||||
def H(stringName):
|
||||
return lambda *children, **attrs: _H(stringName, *children, **attrs)
|
||||
|
||||
p = H("p")
|
||||
a = H("a")
|
||||
span = H("span")
|
||||
|
||||
|
||||
def Element(message:str)->str:
|
||||
return p(onClick="lolidk")(
|
||||
message,
|
||||
span(classes="")("anyone there?")
|
||||
)
|
Loading…
Reference in New Issue
Block a user