From d679ce284a30020392118223cbdd0d7806bb6180 Mon Sep 17 00:00:00 2001 From: Ken Kinder Date: Sat, 3 Aug 2024 09:56:31 +0100 Subject: [PATCH] Reduce the number of unnecessary underscores in ref generation. --- puepy/core.py | 7 ++++--- 1 file changed, 4 insertions(+), 3 deletions(-) diff --git a/puepy/core.py b/puepy/core.py index 330bd6d..bf4e7e6 100644 --- a/puepy/core.py +++ b/puepy/core.py @@ -831,9 +831,10 @@ def generate_tag(self, tag_name, *children, **kwargs): raise Exception("t.generate_tag called without a context") # Determine ref value - ref_part = f"__{parent.ref}.{tag_name}{len(parent.children) + 1}_" + binascii.hexlify( - hashlib.sha256(str(kwargs).encode()).digest() - )[:8].decode("utf8") + ref_part = "__" + ( + f"{parent.ref}.{tag_name}{len(parent.children) + 1}_" + + (binascii.hexlify(hashlib.sha256(str(kwargs).encode()).digest()))[:8].decode("utf8") + ).lstrip("_") ref = kwargs.pop("ref", ref_part)