Html heex v 1.15.2 error / different from 1.14.3


In Elixir version 1.15, I want to call the attribute like this: <img src={} class="theclass"> in html.heex file. However, it’s showing an error that the src attribute should be enclosed with double quotes, but when I use double quotes, the variable is not being interpolated correctly. It should produce the output of the YouTube ID stored in the database, for example: <img src="IYEWBHSs" class="theclass">.

In Elixir version 1.14, even without the double quotes, the variable interpolation works correctly. I’ve also tried using the # symbol like this: <img src="#{}" class="theclass">, but it still fails.

Please help me understand what could be causing this issue and how to correctly interpolate the variable within the src attribute in Elixir version 1.15.

Thank you.

Can you show this error as well as what is shown in the browser?

I think you may be mistaken here (or I am). HEEx doesn’t interpolate sytax unless the entirety of the attribute is enclosed in curly braces. (Or maybe that’s changed… or maybe I’m wrong altogether.)

For your example, try this:

<img src={"#{}"} class="theclass">

you save my day, THANKS heheh

i finally i can do echo stuff in heex file

<%= for photo ← @pathways do %>

<img class=“bostami-client-slider-logo”
src={“/assets/pathway/#{}”} alt=“”>