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 buildRowSetFromString list are plain strings: {{this}} renders the value, {{Value}} renders nothing.
Show Next test script
<!-- Marketing Cloud Next test script for the slice helper. Paste it into the HTML component of a
     Next email and open the preview. Each line prints the result Next gave when the call
     was rendered on its own (expect) next to the result of this run (got).
     Assembled from single-call test emails (dates on the page); it has not been
     run as one email. Calls that make Next fail are listed separately. -->
<p>c1 expect=[gated] got=[{{#if false}}{{slice probeList 1 3}}{{/if}}gated]</p>
<p>c2 expect=[[b][c]] got=[{{#each (slice (buildRowSetFromString "a|b|c|d|e" "|") 1 3)}}[{{this}}]{{/each}}]</p>

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.

See also