website/layouts/partials/helpers/svg.html

7 lines
270 B
HTML

{{ $svg := .path }}
{{ $match := `<svg((\s|\S)*)>((\s|\S)*)</svg>` }}
{{ $input := (printf "/assets/images/%s.svg" $svg | readFile) }}
{{ $replaceWith := printf `<svg class="%s" ${1}>${2}</svg>` .class }}
{{ return (replaceRE $match $replaceWith $input | safeHTML) }}