1{{/* Icon helper: references the shared external sprite (see icon-sprite.html)
2 instead of inlining the SVG, keeping page HTML small. Preserves the
3 original <svg> attributes (viewBox, width, height, …) for sizing and
4 adds an icon-specific class for styling. */}}
5{{- $svg := . -}}
6{{- $class := printf "%s-icon" $svg -}}
7{{- $sprite := partialCached "icon-sprite.html" "sprite" -}}
8{{- $file := printf "/assets/images/%s.svg" $svg | readFile -}}
9{{- $clean := replaceRE `(?s)^(?:\s*<\?xml[^>]*>\s*)?(?:\s*<!--.*?-->\s*)*` "" $file -}}
10{{- $attrs := replaceRE `(?s)^.*?<svg\s*([^>]*?)>.*$` "$1" $clean -}}
11{{- return (printf `<svg class="%s" %s><use href="%s#%s"></use></svg>` $class $attrs $sprite $svg | safeHTML) -}}