# Handlebars Helpers
Email Hero provides a set of custom Handlebars helpers to extend the functionality of your templates. Below is a comprehensive guide to using these helpers.
# 1. each
Helper
# Description:
The each
helper is used to iterate over an array with options to limit the number of iterations and to skip a certain number of elements.
# Usage:
# Parameters:
array
: The array to iterate over.limit
: (Optional) The maximum number of items to iterate over.skip
: (Optional) The number of items to skip before starting the iteration.
# Example:
This example will display information for three products, starting with the second item in the products
array.
# 2. AND
Helper
# Description:
The AND
helper returns true
if all the provided arguments are truthy.
# Usage:
# Example:
This example checks if the user is both active and verified before showing a welcome message.
# 3. OR
Helper
# Description:
The OR
helper returns true
if any of the provided arguments are truthy.
# Usage:
# Example:
This example checks if the user is either an admin or a moderator.
# 4. NOT
Helper
# Description:
The NOT
helper returns the opposite (boolean negation) of the provided argument.
# Usage:
# Example:
This example checks if the user is not a guest.
# 5. EQ
Helper
# Description:
The EQ
(equals) helper checks if two values are strictly equal (===
).
# Usage:
# Example:
This example checks if the user has a premium subscription.
# 6. INCLUDES
Helper
# Description:
The INCLUDES
helper checks if an array contains a specific value.
# Usage:
# Example:
This example checks if the user's roles array includes 'admin'.
# 7. CAPITALIZE
Helper
# Description:
The CAPITALIZE
helper converts a string to uppercase.
# Usage:
# Example:
If user.name
is "john doe", this will output: <p>JOHN DOE</p>
.
# 8. TRUNCATE
Helper
# Description:
The TRUNCATE
helper truncates a string to a specified number of characters, appending "..." if the string is longer than the specified length.
# Usage:
# Parameters:
text
: The text to truncate.characterNum
: The maximum number of characters before truncation.
# Example:
This will output: <p>This is an example of a very...</p>
These helpers allow you to perform various logical, string, and array operations directly within your Handlebars templates, giving you more power and flexibility in your email templates.