Template image display code will not compile

I’m trying to do something really simple, to display an image that is located in the /priv/static/images directory, namely the one that is there by default, phoenix.png.

I’ve replaced the entire .../templates/page/index.html.heex contents with this simple line:

<img src="<%= Routes.static_path(@conn, "/images/phoenix.png") %>"/>

But I’m getting a compile error. Any clues?

Any time you make a post about an error, please always include the full error copied and pasted.

I’m pretty sure your issue is that you’re using old style eex interpolation, and not heex interpolation which would be:

<img src={Routes.static_path(@conn, "/images/phoenix.png")} />
1 Like