Genie Discord forum

Author AvatarJazzdude
10/26/2023, 9:47:32 AM

I'm trying to create an img from a BASE64 encoded mime string that is generated by julia. I'm having a hard time figuring out how to interpolate a tag attribute. The null syntax is just ignored by the HTML renderer. Here's what I have: '''HTML <img src="data:image/png;base64,null" alt="null"" />

null

''' The paragraph content is properly interpolated, but the alt and src attributes are not. What is the correct way to achieve attribute interpolation?

Thanks!

Author AvatarPere
10/26/2023, 10:10:05 AM

This is a limitation of Vue.js. If you open the chrome console you should see error messages about how interpolation in parameters is no longer allowed.

You can work around this by prefixing the argument tags with : so that they accept JS expressions. Then, you can simply pass the variable names or an expression concatenating strings like this

using GenieFramework
@genietools

@out myimage="hello.png"

ui = """HTML
    <img :src="'data:image/png;base64,'+myimage" :alt="myimage" />
    <p>{{myimage}}</p>
"""

@page("/", ui)
up()
Author AvatarJazzdude
10/26/2023, 10:19:26 AM

Thanks! You've saved my day!