---
title: "process-each"
manual: "Handlebars"
version: "main"
permalink: "https://docs.typo3.org/permalink/cpsit/typo3-handlebars:data-processor-process-each@main"
source: "Usage/DataProcessors/ProcessEach.rst"
rendered: "2026-09-29T09:05:57+00:00"
---

# process-each {#data-processor-process-each}

**Class:** `\CPSIT\Typo3Handlebars\DataProcessing\ProcessEachProcessor`

Iterates over an array (or other iterable) and, for each item, evaluates a
`variables` configuration block and/or runs a nested
`dataProcessing` chain against that single item. This is the
usual way to enrich or reshape every entry of an array produced by an
earlier processor — for example, running `object-access`
against each file reference returned by TYPO3's core `files`
processor.

-   [Resolving the items to iterate](https://docs.typo3.org/permalink/cpsit/typo3-handlebars:resolving-the-items-to-iterate@main)
-   [Usage](https://docs.typo3.org/permalink/cpsit/typo3-handlebars:usage@main)
-   [Per-item processing](https://docs.typo3.org/permalink/cpsit/typo3-handlebars:per-item-processing@main)
-   [Properties](https://docs.typo3.org/permalink/cpsit/typo3-handlebars:properties@main)

## Resolving the items to iterate {#data-processor-process-each-source}

The value to iterate over is resolved in the following order:

1.  `dataSource`, if configured (see
    [Referencing data](https://docs.typo3.org/permalink/cpsit/typo3-handlebars:usage-data-sources-payload@main)).
1.  Otherwise, an inline `data` array configured directly on
    this processor.
1.  Otherwise, a `data` key already present in
    `processedData`. This makes `process-each` usable as a
    nested processor inside TYPO3's core processors such as
    `database-query` or `menu` — which expose each
    record as `data` to their nested `dataProcessing`
    chain — without having to repeat `dataSource` explicitly.

If none of these yield an iterable value, the processed data is returned
unchanged.

## Usage {#data-processor-process-each-usage}

```typoscript
tt_content.textpic = HANDLEBARSTEMPLATE
tt_content.textpic {
    templateName = @textpic

    dataProcessing {
        10 = files
        10 {
            references.fieldName = image
            as = files
        }

        20 = process-each
        20 {
            dataSource = processedData:files
            as = processedFiles

            dataProcessing {
                10 = object-access
                10 {
                    object.current = 1
                    path = publicUrl
                    as = url
                }

                20 = object-access
                20 {
                    object.current = 1
                    path = fileType
                    as = type
                }
            }
        }
    }
}
```

Each file reference resolved by the core `files` processor is
set as the content object's current value while the nested
`dataProcessing` chain runs, so `object-access` can
pull individual properties off it with `object.current = 1`
(see [Using the current value](https://docs.typo3.org/permalink/cpsit/typo3-handlebars:usage-data-sources-current@main)). The per-item results are collected — keyed by
the original array keys — under `processedFiles`.

## Per-item processing {#data-processor-process-each-per-item}

Two mechanisms are available for each item, and can be combined:

-   **`variables`**

    A `variables` block, processed exactly like the top-level
    `variables` of `HANDLEBARSTEMPLATE`, but with the
    content object's *current value* set to the item. Use
    `current = 1` (instead of `field`) to reference
    the item itself:

    ```typoscript
    20 = process-each
    20 {
        dataSource = processedData:tags
        as = processedTags

        variables {
            label = TEXT
            label.current = 1
            label.case = upper
        }
    }
    ```

    `data` and `current` are reserved and cannot be
    used as variable names here.

-   **`dataProcessing`**

    A standard nested `dataProcessing` chain (see
    [Usage](https://docs.typo3.org/permalink/cpsit/typo3-handlebars:data-processor-process-each-usage@main)), with the item set as current
    value. Its result is merged with — and overrides —
    whatever `variables` produced for the same item.

## Properties {#data-processor-process-each-properties}

-   **`data`**

    Inline data to iterate over, used if `dataSource` is not
    configured (see [Resolving the items to iterate](https://docs.typo3.org/permalink/cpsit/typo3-handlebars:data-processor-process-each-source@main)).

-   **`dataSource`**

    Data source(s) to read the iterable from (see
    [Resolving the items to iterate](https://docs.typo3.org/permalink/cpsit/typo3-handlebars:data-processor-process-each-source@main)).
    `dataSource.current` uses the content object's current value
    instead (see [Using the current value](https://docs.typo3.org/permalink/cpsit/typo3-handlebars:usage-data-sources-current@main)).

-   **`as`**

    Target key in the processed data array the resulting (keyed) array is
    stored under. Default: `result`.

-   **`variables`**

    Per-item variables block (see
    [Per-item processing](https://docs.typo3.org/permalink/cpsit/typo3-handlebars:data-processor-process-each-per-item@main)).

-   **`dataProcessing`**

    Per-item nested data processors (see
    [Per-item processing](https://docs.typo3.org/permalink/cpsit/typo3-handlebars:data-processor-process-each-per-item@main)).
