Handlebars Helper Function: hash

Constructs an object from key-value pairs. Use this helper as a subexpression to pass structured data as a named parameter to other functions, such as queryFirst.

note: Use this helper only as a subexpression within other functions.

Availability

This helper is available in the Summer ’26 release of Marketing Cloud Next.

Syntax

There are two ways to specify values for this helper. You can specify values by using the equals operator, as in this example:

(hash key1=value1 key2=value2 ...)

You can also specify values by using positional pairs of keys and values:

(hash key1 value1 key2 value2 ...)

Return Value

The function returns a map (LinkedHashMap) that contains all of the specified key-value pairs. The function preserves the order of the key-value pairs.

Usage Examples

This example creates a simple object that contains literal values.

{{hash name="Alice" age=30}}

The function returns a simple hashmap object: {name=Alice, age=30}.

Using Variable References

You can specify variables as key values, as shown in this example:

{{hash greeting=firstName status="active"}}

The returned object includes the value of the firstName variable for the greeting key.

Using with QueryFirst

This example uses the hash helper to provide search parameters to the queryFirst helper.

{{queryfirst type="CRM" object="Account"
  where="Name LIKE :search"
  params=(hash search="Acme%")}}

See Also