29 lines
839 B
Python
29 lines
839 B
Python
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 CustomComponent(message:str)->str:
|
|
return p(onClick="toggleMenu")(
|
|
message,
|
|
span(classes="")("anyone there?")
|
|
)
|
|
|
|
print(CustomComponent("Hello World!")) |