If else comprehension in elixir expressions (phoenix templates)

I think a simpler solution might be to select the source in for. Additionally you could use || in this case. But otherwise if(@formatter_things != nil, do: @formatted_things, else: @unformatted_things) also works as an expression.

<%= for thing <- @formatted_things || @unformatted_things do %>
 <%= thing.name %>
 <%= thing.age %>
 <%= thing.whatever %>
<% end %>
5 Likes