Templating data in HTML
Not sure if you really wanted dynamic variable names like imgurl1 or not, but something like this?

&lt;div class="row"&gt;
{% for entry in entries %}
    {% set loopIndex = loop.index %}
    &lt;div&gt;&lt;p&gt;text{{loopIndex}}&lt;/p&gt;&lt;img src="{{ _context['imgurl' ~ loopIndex] }}" /&gt;&lt;/div&gt;
    {% if loopIndex is divisible by(3) %}
        {% if not loop.last %}
            &lt;/div&gt;
            &lt;div class="row"&gt;
        {% endif %}
    {% endif %}
{% endfor %}
&lt;/div&gt;