readFile from resource

I want to read an SVG-file to inline it in the page. It works perfectly well with readFile and safeHTML but unfortunately I have to pass a path relative to the content-root. Is there any way to use readFile with resources? This would be super-handy as I’m using page-bundles and want to put the SVG-file in the same directory as the

You don’t need readFile, you can do {{ $mysvgResource.Content }}

I just tried it with the following partial:

{{ $svg := .Page.Resources.GetMatch "test.svg" }}
{{ $svg.Content | safeHTML }}

unfortunately, the content is getting escaped, hence the SVG is not being rendered. Any ideas?


{{ $svg.Content | htmlUnescape | safeHTML }}
1 Like

Works perfectly, thanks!