I'm using Go to send a Base64 string to a HTML template and display it as an image, however I'm unsure the best way to go about it. I'm currently URL encoding it and then using {{.}} to display in the .html file, e.g:
app.go
return c.Render(http.StatusOK, "display", url.QueryEscape(string(b64String)))
display.html
<img src={{.}}>
When run and the source code is viewed, it displays:
<img src=data%3Aimage%2Fpng%3Bbase64%2C+iVBORw0KGgoAAAANSUhEUgAAADIAAAAyCAMAAAAp4XiDAAADAFBMVEUDAwIIBgQKCQkaGBZGTVWGj5RAPD%2Beop0rLzdESFAoKzGpqZoPDQuAh496hY%2BHiINKUVk7ODuBjJOTm5yJkpc9QUikpp1eZGtrcXS4rYu9roVlZ2tNTFAwNDtudXhF .....
However, I want it to display as:
<img src="data:image/png;base64, iVBORw0KGgoAAAANSUhEUgAAADIAAAAyCAMAAAAp4XiDAAADAFBMVEUDAwIIBgQKCQkaGBZGTVWGj5RAPD+eop0rLzdESFAoKzGpqZoPDQuAh496hY+HiINKUVk7ODu....">
How do I go about this? I've tried not URL encoding the Base64 when sending it to the .html file, however, that returns:
<img src=#ZgotmplZ>
which isn't correct.