Simplify Heroicon SVG template

This commit is contained in:
Gabriel Arazas 2022-10-24 12:59:05 +08:00
parent 7ea6088f86
commit 1eb8a3b600

View File

@ -1,9 +1,8 @@
{{- /*
This template applies an ID to an SVG from the Heroicons set to be used with `<use>` element.
*/ -}}
{{- $match := "<svg (.*)?>\\s*(.*)\\s*</svg>" }}
{{- $match := "^\\s*<svg (.*)?>" }}
{{- $icon := resources.Get (printf "svg/heroicons/24/solid/%s.svg" .) }}
{{- $replaceWith := printf `<svg id="%s" ${1}>${2}</svg>` . }}
{{- replaceRE $match $replaceWith $icon.Content | safeHTML }}
{{- $replaceWith := printf `<svg id="%s" ${1}>` . }}
{{- replaceRE $match $replaceWith $icon.Content | safeHTML -}}