Handlebars Helper Function: encodeURIComponent

Encodes non-URL components of a string.

This function encodes only characters that follow a URL, such as a query string. To encode an entire string, use encodeURI.

Availability 

This helper is available in the Winter ’27 release of Marketing Cloud Next.

Syntax 

1{{encodeURIComponent stringToEncode}}

Parameters 

ParameterTypeDescription
stringToEncodeStringRequired. The string to encode.

Return Value 

The function returns the URL-encoded string.

Usage Example 

This example encodes a string of text so that it’s safe to include in a URL, converting all spaces and special characters.

1{{encodeURIComponent
2  "https://www.example.com/app?firstName=Cruz&lastName=De La Rosa&email=cdelarosa@example.com"
3}}

The function returns this URL-encoded string:

1https://www.example.com/app?firstName=Cruz&lastName=De+La+Rosa&email=cdelarosa%40example.com

See Also