Heex not interpolated

I have a flash printing partial - which I am rendering in both liveview and regular view.
My flash message printing partial is named notification.html.heex and is in layouts folder. It is something like this

<%= if @content do %>
<div phx-value-key="{@type}"
     id="flash-{@type}-{Timex.to_gregorian_microseconds(Timex.now())}"
  <p class="text-sm font-medium leading-5 text-white">
          <%= @content %>
  </p>
</div>

Now, I am rendering this partial in both app.html.heex and live.html.heex
In live.html.heex I have a statement like

<%= render DemoWeb.LayoutView, "_notification.html", content: live_flash(@flash, :info), type: "info" %>
<%= render DemoWeb.LayoutView, "_notification.html", content: live_flash(@flash, :warning), type: "warning" %>

In app.html.heex I have a statement like

<%= render DemoWeb.LayoutView, "_notification.html", content: live_flash(@conn, :info), type: "info" %>
<%= render DemoWeb.LayoutView, "_notification.html", content: live_flash(@conn, :warning), type: "warning" %>

Now, the partial is getting rendered correctly in live.html.heex but it is not working fine in app.html.heex
When I inspect the HTML that is generated, the interpolation for @type is not happening. The entire code is just getting sent as it is.
What could be the issue?

Don’t put quotes before and after {}

Try with

<div phx-value-key={@type}
     id={"flash-#{@type}-#{Timex.to_gregorian_microseconds(Timex.now())}"} >
2 Likes

Such a silly mistake. Thanks @thomas.fortes