commit d90686c5d5fb0c0d6c73942fb0ed537d2eaf7f63 Author: Seth Trowbridge Date: Tue Mar 19 16:46:44 2024 -0400 init diff --git a/pyx.py b/pyx.py new file mode 100644 index 0000000..112f08b --- /dev/null +++ b/pyx.py @@ -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)}" + +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?") + ) \ No newline at end of file