PruitIgoe
PruitIgoe

Reputation: 6384

Liquid: Why am I getting an Invalid Integer Error

I'm trying to do a loop:

<table class="table">

            {% assign bidderCount = site.bidders | size | divided_by: 4.0 %}
            {% for i in (1..bidderCount) %}
            <tr>
                <td>Item 1<td>
                <td>Item 1<td>
                <td>Item 1<td>
                <td>Item 1<td>

            </tr>
            {% endfor %}
        </table>

When I check bidderCount it outputs the correct number but when I plug that into the loop syntax I get an Invalid Integer Error. Is this not allowed in liquid?

Upvotes: 0

Views: 904

Answers (1)

Robert Del Favero
Robert Del Favero

Reputation: 141

According to the Liquid docs, divided_by returns the type of the divisor, which in your case is 4.0 -- a float. Floats are not valid integers.

Try this in your example, instead: dividing by an integer so the result is an integer:

{% assign bidderCount = site.bidders | size | divided_by: 4 %}

Upvotes: 2

Related Questions