Handlebars substring
Handlebars substring: returns part of a string, counting positions from 1.
Next
Runtime verified
Differs from official docs
Test scripts included
Returns part of a string, counting positions from 1.
Syntax
{{substring subject start [length]}}
Returns string.
Parameters
| Name | Type | Required | Description |
|---|---|---|---|
subject |
string | Yes | Source string. |
start |
integer | Yes | Starting position. Position 1 is the first character. |
length |
integer | No | Number of characters to extract. |
Example
Tested in a Marketing Cloud Next email on 2026-11-22:
{{substring "abcdef" 2 3}}rendersbcd, as documented.{{{substring "<i>abc</i>" 1 6}}}renderscom.salesforce.e360.messaging.rendering.helper.HandlebarResultWrapper@539b5bf2.
Show Next test script
Differs from official docs
- The reference does not say that the helper cannot be used with triple braces, the usual Handlebars way to output a value without HTML escaping. In Marketing Cloud Next (tested 2026-11-22):
{{{substring "<i>abc</i>" 1 6}}}renderedcom.salesforce.e360.messaging.rendering.helper.HandlebarResultWrapper@539b5bf2instead of the text. With double braces the helper works:{{substring "abcdef" 2 3}}renderedbcd. Details
Marketing Cloud Next
Differs from the documentation
With double braces every tested call rendered as documented. With triple braces, {{{substring "<i>abc</i>" 1 6}}} renders the name of an internal Java object (com.salesforce…HandlebarResultWrapper@…) instead of the text. Tested 2026-11-22 by rendering in a Marketing Cloud Next email.
See also
- AMPscript
Substring— the AMPscript equivalent - Official reference