Handlebars slice
Handlebars slice: returns part of a list, from a start index up to but not including an end index.
Next
Runtime verified
Test scripts included
Returns part of a list, from a start index up to but not including an end index.
Syntax
{{slice list startIndex [endIndex]}}
Returns array.
Parameters
| Name | Type | Required | Description |
|---|---|---|---|
list |
array | Yes | Source list. |
startIndex |
integer | Yes | The starting index. Negative counts from the end. |
endIndex |
integer | No | The ending index (exclusive). Negative counts from the end. |
Example
Tested in a Marketing Cloud Next email on 2026-11-25, alone in the email:
{{#each (slice (buildRowSetFromString "a|b|c|d|e" "|") 1 3)}}[{{this}}]{{/each}}renders[b][c], as documented: the start index is included, the end index is not.- The items of a
buildRowSetFromStringlist are plain strings:{{this}}renders the value,{{Value}}renders nothing.
Show Next test script
Marketing Cloud Next
Works as documented
Every tested call rendered the documented result. Tested 2026-11-25 by rendering in a Marketing Cloud Next email.