Renders the block if the test string begins with the specified prefix. If it doesn't match, renders the {{else}} block.
{{#startsWith prefix testString}}Block if match{{else}}Fallback{{/startsWith}}
-
prefix (required): the prefix to check for
-
testString (required): string to test against
Note
This helper produces an empty string when either the prefix or testString parameter is missing, undefined, or when the helper call is malformed.
-
Check if a greeting starts with "Hello"
{{#startsWith "Hello" record.greeting}}Match!{{else}}No match{{/startsWith}} {{#startsWith "Goodbye" record.greeting}}Wrong!{{else}}Still here{{/startsWith}}Input:
{ "record": { "greeting": "Hello, world!" } }Output:
Match! Still here
-
Check if a customer name starts with "Jane"
{{#startsWith "Jane" record.firstName}} Welcome, Jane! {{else}} User not Jane {{/startsWith}}Input:
{ "record": { "firstName": "Jane Doe" } }Output:
Welcome, Jane!
Tip
-
Matching is case-sensitive (
"Hello"≠"hello"). -
Use when validating prefixes in IDs, codes, or user inputs.