Handlebars each
Handlebars each: renders its block once for every item in an array, list or object.
Next
Runtime verified
Test scripts included
Renders its block once for every item in an array, list or object.
Syntax
{{#each collection}}
…
{{/each}}
Returns string.
Parameters
| Name | Type | Required | Description |
|---|---|---|---|
collection |
array | Yes | The array, list or object to loop over. |
Example
Tested in Marketing Cloud Next emails on 2026-11-22 and 2026-11-25:
{{#each (hash a="1" b="2")}}{{@key}}={{this}};{{/each}}rendersa=1;b=2;, as documented.- With a list of two rows built in AMPscript (
%%[ SET @rows = BuildRowsetFromJSON('[{"name":"Bob","age":27},{"name":"Ann","age":21}]', '$[*]', 1) ]%%),{{#each rows}}{{@index}}={{name}};{{/each}}renders0=Bob;1=Ann;. {{#each (jsonpath '[1,2,3]' "$")}}[{{this}}]{{/each}}renders[1][2][3].
Show Next test script
Marketing Cloud Next
Works as documented
Looping over an object or a list rendered as documented. Rows built in AMPscript and arrays from jsonpath both work as lists. Tested 2026-11-25 by rendering in a Marketing Cloud Next email.