Handlebars Helper Documentation
This documentation provides details and examples for each custom Handlebars helper defined in the provided code.
Checks if the provided context is an array.
Example:
{{#isArray myArray}}
<!-- Code to execute if myArray is an array -->
{{else}}
<!-- Code to execute if myArray is not an array -->
{{/isArray}}
Formats a date according to the specified format, locale, and timezone.
Example:
{{formatDate "2023-01-01T12:00:00" "medium" "en-us" "+05:30"}}
Formats a date and time according to the specified format, locale, and timezone.
Example:
{{formatDateTime "2023-01-01T12:00:00" "medium" "en-us" "+05:30"}}
Removes specified strings from the input string.
Example:
{{remove "Hello, world!" "world"}}
Checks if the provided context is a JSON object.
Example:
{{#isJSON myObject}}
<!-- Code to execute if myObject is a JSON object -->
{{else}}
<!-- Code to execute if myObject is not a JSON object -->
{{/isJSON}}
Conditionally executes code based on equality.
Example:
{{#ifEquals variable1 variable2}}
<!-- Code to execute if variable1 equals variable2 -->
{{else}}
<!-- Code to execute if variable1 does not equal variable2 -->
{{/ifEquals}}
Converts an object to as json string
Example:
Parses a JSON string into an object.
Example:
{{#parse jsonString}}
<!-- Access properties of the parsed object -->
{{property1}}
{{/parse}}
Checks if a string matches a regular expression.
Example:
{{#ifMatches myString "pattern"}}
<!-- Code to execute if myString matches the pattern -->
{{else}}
<!-- Code to execute if myString does not match the pattern -->
{{/ifMatches}}
Returns the raw content without rendering Handlebars expressions.
Example:
{{#raw-helper}}
<p>This is raw HTML content: {{variable}}</p>
{{/raw-helper}}
Checks if the provided string is a valid email address.
Example:
{{#isEmail "user@example.com"}}
<!-- Code to execute if the email is valid -->
{{else}}
<!-- Code to execute if the email is not valid -->
{{/isEmail}}
Extracts a number from the given text.
Example:
{{getNumberFromText "The price is $500"}}
Provides a default value if the key is falsy.
Example:
{{default myKey "Default Value"}}
Conditionally executes code based on whether a string starts with a specified prefix.
Example:
{{#ifStartsWith myString "prefix"}}
<!-- Code to execute if myString starts with "prefix" -->
{{else}}
<!-- Code to execute if myString does not start with "prefix" -->
{{/ifStartsWith}}
Extracts the Expo token from a string if present.
Example:
{{isExpo "expo_token:ABC123"}}
Extracts the FCM token from a string if present.
Example:
{{isFCM "fcm_token:XYZ789"}}
Extracts Onesignal selector and token from a string if present.
Example:
{{#isOnesignal "onesignal_player_id:12345"}}
<!-- Access properties: {{onesignal_selector}}, {{onesignal_token}} -->
{{else}}
<!-- Code to execute if the string does not match Onesignal format -->
{{/isOnesignal}}
Checks if an object is empty.
Example:
{{#isEmpty myObject}}
<!-- Code to execute if myObject is empty -->
{{else}}
<!-- Code to execute if myObject is not empty -->
{{/isEmpty}}
Sets a variable in the root context.
Example:
{{setVariable "myVar" "myValue"}}
Pushes callback information into the root context.
Example:
Generates a notification ID based on the provided key.
Example:
{{generateNotifyId "myKey"}}
Calculates the difference between two dates.
Example:
{{dateDiff "2023-01-01T12:00:00" "NOW" "days"}}
Compares two values based on the specified operator.
Example:
{{#compare value1 "eq" value2}}
<!-- Code to execute if value1 equals value2 -->
{{else}}
<!-- Code to execute if value1 does not equal value2 -->
{{/compare}}
24. eq, ne, lt, gt, lte, gte, and, or
Logical comparison helpers.
Example:
{{#eq variable1 variable2}}
<!-- Code to execute if variable1 equals variable2 -->
{{/eq}}
Splits a string into an array using a specified delimiter.
Example:
{{#split "apple,orange,banana" ","}}
<!-- Access individual elements in the array -->
{{this}}
{{/split}}
Performs basic arithmetic operations on two values.
Example:
Determines the relationship of a given date to the current date.
Example:
{{relativeDay "2023-01-01"}}
Trims a string to a specified length and delimiter.
Example:
{{trim "This is a long string" 10 "..."}}
Formats a number using the specified locale.
Example:
{{formatNumber 1234567.89 "en-US"}}