fix bug in Component

A leftover from when there was only the A component function,
this bug was not found earlier because we used
templates instead of tags most of the time.
This commit is contained in:
Lukáš Kucharczyk 2024-09-14 10:40:03 +02:00
parent 649351efde
commit c40764a02f
Signed by: lukas
SSH Key Fingerprint: SHA256:vMuSwvwAvcT6htVAioMP7rzzwMQNi3roESyhv+nAxeg
4 changed files with 8 additions and 3 deletions

View File

@ -21,11 +21,16 @@ def Component(
if isinstance(children, str): if isinstance(children, str):
children = [children] children = [children]
childrenBlob = "\n".join(children) childrenBlob = "\n".join(children)
attributesList = [f'{name} = "{value}"' for name, value in attributes] if len(attributes) == 0:
attributesBlob = " ".join(attributesList) attributesBlob = ""
else:
attributesList = [f'{name}="{value}"' for name, value in attributes]
# make attribute list into a string
# and insert space between tag and attribute list
attributesBlob = f" {" ".join(attributesList)}"
tag: str = "" tag: str = ""
if tag_name != "": if tag_name != "":
tag = f"<a {attributesBlob}>{childrenBlob}</a>" tag = f"<{tag_name}{attributesBlob}>{childrenBlob}</{tag_name}>"
elif template != "": elif template != "":
tag = render_to_string( tag = render_to_string(
template, template,