Targeting every 3rd, 6th, 9th etc element of a list
<p>I am using twig templating to loop though an array of items which would display as a grid with 3 items in a row. If there is an empty space at the end of the row I have a block that would be placed there, but only of there is one empty space. The below covers what I require but feels a bit clunky. </p>

<pre><code>{% if items|length == 2 or items|length == 5 % or items|length == 8 %}
 // add a block to fill the space
{% endif %}
</code></pre>

<p>With jQuery I would do something like the below:</p>

<pre><code>jQuery('#item:nth-child(3n+3)')
</code></pre>

<p>Is there a smarter way via the twig if statement to do the same?</p>