---
title: "forloop"

doc_type: static
doc_category: static
doc_version: v20260901
source_url:
  html: 'https://developer.shopline.com/docs/handlebars/objects/forloop'
  md: 'https://developer.shopline.com/docs/handlebars/objects/forloop.md'
---


# forloop

<div class="code-flex">
  <div>
    <ObjectSummary>
      Information about a parent [for loop](https://developer.shopline.com/docs/handlebars/helpers/iteration/for.md).
    </ObjectSummary>

    #### Properties

    <ObjectProperty name="first" types={['boolean']}>
      <ObjectSummary>
        Returns `true` if the current iteration is the first. Returns `false` if not.
      </ObjectSummary>
    </ObjectProperty>

    <ObjectProperty name="index" types={['number']}>
      <ObjectSummary>
        The 1-based index of the current iteration.
      </ObjectSummary>
    </ObjectProperty>

    <ObjectProperty name="index0" types={['number']}>
      <ObjectSummary>
        The 0-based index of the current iteration.
      </ObjectSummary>
    </ObjectProperty>

    <ObjectProperty name="last" types={['number']}>
      <ObjectSummary>
        Returns `true` if the current iteration is the last. Returns `false` if not.
      </ObjectSummary>
    </ObjectProperty>

    <ObjectProperty name="length" types={['number']}>
      <ObjectSummary>
        The total number of iterations in the loop.
      </ObjectSummary>
    </ObjectProperty>

    <ObjectProperty name="parentloop" types={[<Mdx>[forloop](https://developer.shopline.com/docs/handlebars/objects/forloop.md)</Mdx>]}>
      <ObjectSummary>
        The parent `forloop` object.

        If the current `for` loop isn't nested inside another `for` loop, then `null` is returned.
      </ObjectSummary>

      <strong>Use the parentloop property</strong>

      <Example data={['collection.products']} layout="vertical">
      ```handlebars
      {{#for collection.products as |product|}}
        {{#for collection.products as |product|}}
          {{ forloop.parentloop.index }} - {{ forloop.index }}
        {{/for}}
      {{/for}}
      ```
      </Example>
    </ObjectProperty>

    <ObjectProperty name="rindex" types={['number']}>
      <ObjectSummary>
        The 1-based index of the current iteration, in reverse order.
      </ObjectSummary>
    </ObjectProperty>

    <ObjectProperty name="rindex0" types={['number']}>
      <ObjectSummary>
        The 0-based index of the current iteration, in reverse order.
      </ObjectSummary>
    </ObjectProperty>

  </div>

  <div>
    <ObjectAccess
      object="forloop"
      global={false}
      parents={[
        { object: 'forloop.parentloop', link: '/docsv2/ec20/hdwvcvrgnfcjf4gq/fxad3622a715unnb#parentloop' },
      ]}
    />
  </div>
</div>
