Mercurial > libervia-backend
changeset 4353:e22a5d80be02
template: fix name handling for icons.
author | Goffi <goffi@goffi.org> |
---|---|
date | Fri, 11 Apr 2025 18:18:50 +0200 |
parents | 382dc6e62b6e |
children | 4a8bb49b9d0f |
files | libervia/backend/tools/common/template.py |
diffstat | 1 files changed, 8 insertions(+), 6 deletions(-) [+] |
line wrap: on
line diff
--- a/libervia/backend/tools/common/template.py Fri Feb 28 09:23:35 2025 +0100 +++ b/libervia/backend/tools/common/template.py Fri Apr 11 18:18:50 2025 +0200 @@ -1012,13 +1012,15 @@ if "/" in name: raise ValueError("SVG name must not have a `/` in it.") if name.startswith("regular "): - name = name[8:] - path = self.fa_svgs_path / f"regular/{name}.svg" + filename = name[8:] + path = self.fa_svgs_path / f"regular/{filename}.svg" else: if name.startswith("solid "): # "solid" can be explicitely specified, and it's the default value. - name = name[6:] - path = self.fa_svgs_path / f"solid/{name}.svg" + filename = name[6:] + else: + filename = name + path = self.fa_svgs_path / f"solid/{filename}.svg" # Parse the source SVG try: @@ -1038,7 +1040,7 @@ symbol = etree.SubElement( defs_elt, "symbol", - id=name, + id=name.replace(" ", "_"), viewBox=viewbox, ) @@ -1060,7 +1062,7 @@ 'width="1em" height="1em" fill="currentColor" >\n' ' <use href="#{name}"/>' "</svg>\n".format( - name=name, + name=name.replace(" ", "_"), cls=(" " + cls) if cls else "", extra_attrs=" " + extra_attrs if extra_attrs else "", )