website/layouts/partials/helpers/svg.html

8 lines
270 B
HTML
Raw Permalink Normal View History

2023-05-21 20:39:56 +00:00
{{ $svg := .path }}
{{ $match := `<svg((\s|\S)*)>((\s|\S)*)</svg>` }}
2023-05-21 20:39:56 +00:00
{{ $input := (printf "/assets/images/%s.svg" $svg | readFile) }}
2023-05-26 19:44:22 +00:00
{{ $replaceWith := printf `<svg class="%s" ${1}>${2}</svg>` .class }}
2023-05-21 20:39:56 +00:00
{{ return (replaceRE $match $replaceWith $input | safeHTML) }}