Handlebars lookup
Handlebars lookup: dynamically accesses an object property or array element by a variable key.
Next
Runtime verified
Differs from official docs
Test scripts included
Dynamically accesses an object property or array element by a variable key.
Syntax
{{lookup object key}}
Returns any.
Parameters
| Name | Type | Required | Description |
|---|---|---|---|
object |
any | Yes | Object or array to read from. |
key |
any | Yes | Property name or array index to read. |
Example
Tested in Marketing Cloud Next emails on 2026-11-22 and 2026-11-25:
{{lookup (hash k="v") "k"}}rendersv, as documented.{{lookup (hash k="v") "missing"}}renders{k=v}. The documented result is an empty string.- With a list of two rows built in AMPscript (
%%[ SET @rows = BuildRowsetFromJSON('[{"name":"Bob","age":27},{"name":"Ann","age":21}]', '$[*]', 1) ]%%),{{lookup (lookup rows 0) "name"}}rendersBob.
Show Next test script
Differs from official docs
- The reference says that a key which does not exist gives
undefined, which renders as an empty string. In Marketing Cloud Next (tested 2026-11-22):{{lookup (hash k="v") "missing"}}rendered{k=v}, the whole object, instead of an empty string. An existing key,{{lookup (hash k="v") "k"}}, renderedv. Details
Marketing Cloud Next
Differs from the documentation
{{lookup (hash k="v") "k"}} gives v, and looking up a list index works. A key that does not exist renders the whole object, {k=v}, instead of the documented empty string. Tested 2026-11-25 by rendering in a Marketing Cloud Next email.