It is not just anonymous functions, eex does not like non-blocks (like
end) being broken up between different eex statements, it expects everything to be in a single statement as far as my testing has shown me.
At those times I just break up the template into smaller templates and just pass in the anonymous function calls to them, plus it makes the templates smaller and ‘usually’ more readable.
I’ve not tried this, just thought of it, but you could try:
<%= my_function f, fn arg -> ~e"""
""" end, fn arg -> ~e"""
""" end %>
So just embed eex templates in the eex templates (which will not have a run-time overhead at all, eex templates, no matter how deep, inline into an iolist). ^.^