{{ $svg := . }} {{ $class := print $svg "-icon" }} {{ $match := "(.*)" }} {{ $replaceWith := printf `${2}` $class }} {{ return (replaceRE $match $replaceWith (printf "/assets/icons/%s.svg" $svg | readFile) | safeHTML) }} {{/* Taken from https://bitbanged.com/posts/how-to-use-inline-svgs-with-hugo/ */}} {{/* Only works if SVG is on one line! */}}