"no match of … :comprehension" when rendering partial .leex template

I’ve been experimenting with converting a simple dashboard page to LiveView, and I’m getting a strange error that I can’t track down.

I have a sites.html.leex template, rendered from my LiveView, containing the following:

  <%= for site <- @sites do %>
    <%= render "site.html", %{site: site} %>
  <% end %>

This works fine when the page initially loads, but when an event triggers my LiveView’s handle_info to assign a new sites list, the LiveView crashes, with the following error:

[error] GenServer #PID<0.1544.0> terminating
** (MatchError) no match of right hand side value: :comprehension
    (premonition) lib/premonition_web/templates/dashboard/site.html.leex:1: PremonitionWeb.DashboardView."site.html"/1
    (premonition) lib/premonition_web/templates/dashboard/sites.html.leex:3: anonymous fn/2 in PremonitionWeb.DashboardView."sites.html"/1

If I take the contents of the child template (site.html.leex) and paste it inside the list comprehension instead, it works, but I’d prefer not to keep everything in one big template if possible. I initially thought it might not be possible, so I tried modifying the “CRUD Users” sample app from the LiveView project to render a partial template using virtually identical code, and I don’t get the error.

I realise this is pretty much impossible to diagnose from just that description (unless someone’s seem it before and knows what obvious mistake I’ve made), but can anyone suggest where I should be looking to get to the bottom of it?

Many thanks!

It’s not quite the same but seems very similar to this bug report: https://github.com/phoenixframework/phoenix_live_view/issues/189. I guess keep an eye on that issue!


Thank you – that does look similar. I’ll watch that issue, and assume for now that I’m not making some kind of obvious mistake after all!