title: How to remove the last item in jinja nested loop?
body: <p>With a single loop, it's easy to write <code>{% if not loop.last %}JOIN{% endif %}</code> to remove <code>JOIN</code> from the last iteration of the loop.</p>
  
  <p>With nested loop, we can <a href="http://jinja.pocoo.org/docs/dev/tricks/#accessing-the-parent-loop" rel="nofollow noreferrer">access the outer loop</a>, allowing us to check if we're in the final iterations of both loops.</p>
  
  <p>Still, I have a 3-level nested, for which this solution is quite verbose:</p>
  
  <pre><code>{% set loop1 = loop %}
  ...
  {% set loop2 = loop %}
  ...
  {% if not loop1.last and loop2.last and loop.last %}JOIN{% endif %}
  </code></pre>
  
  <p>Is there a better way to skip the last iteration of a nested loop?</p>