I figured out a solution based on your suggestions… I just had to jiggle my EEx tags around. There was an important caveat I had to consider here that makes it a better solution to have this logic done in the template – it has to do with a Handlebars parser I’m writing: GitHub - fireproofsocks/zappa: Elixir implementation of the Handlebars template language · GitHub
In the below example, both the list or map input options work:
input = ["apple", "boy", "cat"]
input = %{x: "xray", y: "yellow"}
eex = ~s"""
<ul>
<%= Enum.with_index(list) |> Enum.map(fn({x, index}) -> %>
<%= if is_tuple(x) do %>
<% {k, v} = x %>
<li><%= k %>: <%= v %></li>
<% else %>
<% this = x %>
<li><%= this %></li>
<% end %>
<%= end) %>
</ul>
"""
out = EEx.eval_string(eex, list: input)
Yes, that looks awful, but this structure will work in my weird use-case.


















