Hi! I'm currently trying to build a ToTp UI in Go,...
# talk-kratos
c
Hi! I'm currently trying to build a ToTp UI in Go, using {{ .Attributes.UiNodeImageAttributes.Src }} I'm trying to get the Base64 code. Except for the <img src"...">, this works and I can read the code and convert it to an image. <img src"{{ .Attributes.UiNodeImageAttributes.Src }}" .../> strangely doesn't work. There I get the following result rendered in my browser: <img src="#ZgotmplZ" id="totp_qr" width="256" height="256"> Does work: <p>{{ .Attributes.UiNodeImageAttributes.Src }}</p> (I see the base64 code as text in the browser) Does not work: <img src="{{ .Attributes.UiNodeImageAttributes.Src }}" id="{{ .Attributes.UiNodeImageAttributes.Id }}" width="{{ .Attributes.UiNodeImageAttributes.Width }}" height="{{ .Attributes.UiNodeImageAttributes.Height }}"/> What am I doing wrong? UPDATE:
Copy code
<script>
   document.querySelectorAll('[id="{{ .Attributes.UiNodeImageAttributes.Id }}"]')[0].src = '{{ .Attributes.UiNodeImageAttributes.Src }}';
</script>
I added that. It works now, but it doesn't seem like a clean solution to me. Strange that it doesn't work in the src attribute.