[RESOLVED, CANNOT REPRODUCE] Declaring readFile'd SVG string output as safe?

Hi all.
I’m trying to get the contents of a .svg file from a page parameter containing its path, and load the resulting string into an <object> tag.

I’ve successfully retrieved the contents of the file and loaded it into a string variable via readFile. However, I’m encountering a problem with Go’s HTML sanitization - whenever I try to output the contents of the file, regardless of piping it to safeHTML or not, it continually redacts the output to ZgotmplZ.

Does anyone know how to get Hugo to recognize my SVG string as safe for output?

Try safeHtmlAttr https://gohugo.io/templates/functions#safehtmlattr

And see if that works.

But why do you have to get the SVG this way?

Aren’t there simpler ways? Can’t you have the SVG inside a partial and call it when you need it inside the <object> tag?

No-go on safeHTMLAttr, sorry. Same issue occurs.

The reason I can’t put this in a partial has to do with how the data is structured in the filesystem - goes a bit past this issue. Long story short, the SVG files have to be under %HUGO_BASE_DIR%/static/, which is why I’m using readFile.

Well if both of these functions fail I’m afraid that I cannot help you further.

Maybe @moorereason has an idea about your issue.

Can you show us how you’re attempting to do this in your template?

I returned to the project this morning, after restarting my development instance, and suddenly the code began working. It seems that the issue has resolved itself, somehow.

Personally, I’m going to file this one under ‘cannot reproduce’, and not look at it again too closely, lest it stop working again.

Thank you for your assistance, and if someone did something on the backend that fixed this, thanks to them as well.