I think doing logic here is a lot cleaner, so let's plan to go with that. (It's awkward to do that computation in the caller because of how the loops are setup, and anyway I think it's more readable to have the conditionals in the template if we don't have to endure stupid nonsense to do so)