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

# iterable-to-array {#data-processor-iterable-to-array}

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

Converts an iterable value — an Extbase `QueryResultInterface` as
returned by a repository, an `ObjectStorage`, a plain `Iterator`,
or a `Generator` — into a plain array. Templates and other data
processors generally expect array data, so this processor is the usual
bridge between a repository result and the rest of the
`dataProcessing` chain.

-   [Data sources](https://docs.typo3.org/permalink/cpsit/typo3-handlebars:data-sources@main)
-   [Usage](https://docs.typo3.org/permalink/cpsit/typo3-handlebars:usage@main)
-   [Processing individual items](https://docs.typo3.org/permalink/cpsit/typo3-handlebars:processing-individual-items@main)
-   [Properties](https://docs.typo3.org/permalink/cpsit/typo3-handlebars:properties@main)

## Data sources {#data-processor-iterable-to-array-data-sources}

`iterable` references the value to convert, e.g. the output of a
preceding processor or a variable assigned by an Extbase controller
(`processedData:news`). See [Referencing data](https://docs.typo3.org/permalink/cpsit/typo3-handlebars:usage-data-sources-payload@main)
for the syntax.

## Usage {#data-processor-iterable-to-array-usage}

**EXT:my_extension/Classes/Controller/NewsController.php**

```php
final class NewsController extends HandlebarsController
{
    public function listAction(): ResponseInterface
    {
        $this->view->assign('news', $this->newsRepository->findAll());

        return $this->htmlResponse($this->renderView());
    }
}
```

```typoscript
plugin.tx_myextension_news.handlebars {
    News::list {
        dataProcessing {
            10 = iterable-to-array
            10 {
                iterable = processedData:news
                as = newsItems
            }
        }
    }
}
```

## Processing individual items {#data-processor-iterable-to-array-nested}

Each converted item is set as the content object's current value while a
nested `dataProcessing` chain runs, so nested processors can
reference it with `current = 1` (see
[Using the current value](https://docs.typo3.org/permalink/cpsit/typo3-handlebars:usage-data-sources-current@main)). This only happens when a nested chain is
actually configured, so plain conversions are left untouched:

```typoscript
dataProcessing {
    10 = iterable-to-array
    10 {
        iterable = processedData:news
        as = newsItems

        dataProcessing {
            10 = object-access
            10 {
                object.current = 1
                path = title
                as = title
            }
        }
    }
}
```

## Properties {#data-processor-iterable-to-array-properties}

-   **`iterable`**

    Data source reference(s) the value to convert is read from (see
    [Data sources](https://docs.typo3.org/permalink/cpsit/typo3-handlebars:data-processor-iterable-to-array-data-sources@main)). Required.

-   **`as`**

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

-   **`preserveKeys`**

    Boolean. When `1`, the original keys of the iterable (e.g.
    array keys or `Generator` keys) are preserved. When `0`,
    the result is reindexed as a plain list. Default: `0`.

-   **`dataProcessing`**

    Nested data processors, run for each item of the converted array (see
    [Processing individual items](https://docs.typo3.org/permalink/cpsit/typo3-handlebars:data-processor-iterable-to-array-nested@main)).

If `iterable` is not configured, or the resolved value is not
iterable, a warning is logged and the processed data is returned unchanged.
