From c40764a02f8dfedbc173fa486246e936211079a0 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Luk=C3=A1=C5=A1=20Kucharczyk?= Date: Sat, 14 Sep 2024 10:40:03 +0200 Subject: [PATCH] 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. --- common/components.py | 11 ++++++++--- .../{nintendoswitch.html => nintendo-switch.html} | 0 .../icon/{physicalmediacddvd.html => physical.html} | 0 .../icon/{xboxgamepass.html => xbox-gamepass.html} | 0 4 files changed, 8 insertions(+), 3 deletions(-) rename games/templates/cotton/icon/{nintendoswitch.html => nintendo-switch.html} (100%) rename games/templates/cotton/icon/{physicalmediacddvd.html => physical.html} (100%) rename games/templates/cotton/icon/{xboxgamepass.html => xbox-gamepass.html} (100%) diff --git a/common/components.py b/common/components.py index a969397..d1130d7 100644 --- a/common/components.py +++ b/common/components.py @@ -21,11 +21,16 @@ def Component( if isinstance(children, str): children = [children] childrenBlob = "\n".join(children) - attributesList = [f'{name} = "{value}"' for name, value in attributes] - attributesBlob = " ".join(attributesList) + if len(attributes) == 0: + 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 = "" if tag_name != "": - tag = f"{childrenBlob}" + tag = f"<{tag_name}{attributesBlob}>{childrenBlob}" elif template != "": tag = render_to_string( template, diff --git a/games/templates/cotton/icon/nintendoswitch.html b/games/templates/cotton/icon/nintendo-switch.html similarity index 100% rename from games/templates/cotton/icon/nintendoswitch.html rename to games/templates/cotton/icon/nintendo-switch.html diff --git a/games/templates/cotton/icon/physicalmediacddvd.html b/games/templates/cotton/icon/physical.html similarity index 100% rename from games/templates/cotton/icon/physicalmediacddvd.html rename to games/templates/cotton/icon/physical.html diff --git a/games/templates/cotton/icon/xboxgamepass.html b/games/templates/cotton/icon/xbox-gamepass.html similarity index 100% rename from games/templates/cotton/icon/xboxgamepass.html rename to games/templates/cotton/icon/xbox-gamepass.html