template: fix name handling for icons.
This commit is contained in:
parent
2346dfb461
commit
ce5ba7123b
1 changed files with 8 additions and 6 deletions
|
|
@ -1012,13 +1012,15 @@ class Renderer(object):
|
|||
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 @@ class Renderer(object):
|
|||
symbol = etree.SubElement(
|
||||
defs_elt,
|
||||
"symbol",
|
||||
id=name,
|
||||
id=name.replace(" ", "_"),
|
||||
viewBox=viewbox,
|
||||
)
|
||||
|
||||
|
|
@ -1060,7 +1062,7 @@ class Renderer(object):
|
|||
'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 "",
|
||||
)
|
||||
|
|
|
|||
Loading…
Reference in a new issue