In a template I have an iteration over some days in an itinerary:
<%= for day <- @days do %>
<tr>
<td><%= day.number %></td>
<td><%= day.main_event_time %></td>
<td><%= day.main_event %></td>
<td><%= day.location %></td>
<td><%= day.who %></td>
<td><%= day.summary %></td>
<td><%= day.lodging %></td>
<td><%= link "Show", to: day_path(@conn, :show, day) %></td>
<td><%= link "Edit", to: day_path(@conn, :edit, day) %></td>
<td><%= link "Delete", to: day_path(@conn, :delete, day), method: :delete %></td>
</tr>
<% end %>
I'd like have a different message come up in the case when there are no days yet. How can I do that?
You can put this before or after your for
comprehension:
<%= if Enum.empty?(@days) do %>
No days yet.
<% end %>
If you love us? You can donate to us via Paypal or buy me a coffee so we can maintain and grow! Thank you!
Donate Us With