website/layouts/partials/helpers/svg.html

6 lines
269 B
HTML

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