How Would You Make A Two Column Table With Twig?

前端 未结 3 1377
渐次进展
渐次进展 2021-02-05 07:30

I can\'t for the life of me figure out how to add a every OTHER iteration in a Twig loop.

For instance:

$numArray = a         


        
3条回答
  •  臣服心动
    2021-02-05 07:53

    The proper way of doing this is using the batch filter. It is new in 1.12.3.

    
    {% for row in numArray|batch(2) %}
      
      {% for column in row %}
        
      {% endfor %}
      
    {% endfor %}
    
    {{ column }}

    Ref: http://twig.sensiolabs.org/doc/filters/batch.html

提交回复
热议问题