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 

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

  1. dataSource , if configured — see Resolving a data payload (dataSource / data) for how it is resolved, including what happens when multiple references are configured.
  2. Otherwise, an inline data array configured directly on this processor.
  3. Otherwise, a data key already present in processedData . This makes process-each usable as a nested processor inside iterable-to-array or object-access — both of which wrap each item as data for their own nested dataProcessing chain — without having to repeat dataSource explicitly.

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

Usage 

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 = contentObjectConfiguration:currentValue
                    path = publicUrl
                    as = url
                }

                20 = object-access
                20 {
                    object = contentObjectConfiguration:currentValue
                    path = fileType
                    as = type
                }
            }
        }
    }
}
Copied!

Each file reference resolved by the core files processor is made available to the nested dataProcessing chain as currentValue , reachable as contentObjectConfiguration:currentValue (see Data sources), so object-access can pull individual properties off it. The per-item results are collected — keyed by the original array keys — under processedFiles .

Per-item processing 

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:

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

    variables {
        label = TEXT
        label.current = 1
        label.case = upper
    }
}
Copied!

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

dataProcessing
A standard nested dataProcessing chain (see Usage), with the item exposed as currentValue . Its result is merged with — and overrides — whatever variables produced for the same item.

Properties 

data
Inline data to iterate over, used if dataSource is not configured (see Resolving the items to iterate).
dataSource
Data source(s) to read the iterable from (see Resolving the items to iterate).
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).
dataProcessing
Per-item nested data processors (see Per-item processing).