I have the following code which checks to see if the image is an svg or other format and attempts to inline the SVG where possible.
{{ range .vendorLogos }}
{{ $format := substr (index .) -1 3}}
{{ if eq $format "svg"}}
{{ $image := index . }}
<img src="{{ $image }}" alt="{{ $image }}">
{{ readFile (print "static/" $image) | safeHTML }}
{{ else }}
<img src="{{ index . }}" alt="{{ index . }}">
{{ end }}
{{ end }}
This line: {{ readFile (print "static/" $image) | safeHTML }} continually outputs the same logo but the line above it outputs correctly so I presume it’s an issue with the readFile function taking too long to execute or am I missing something? Is this a bug?
Sorry, don’t know what your range is looping over … so your question ist to short
.File is a page attribute. If you range over files (used ReadDir ??), .Ext should do it.