Articles in this section

pluck helper

The pluck helper extracts the value of a specified property from each element in an array of objects and returns the results as a new array. Use it to collect a single field across multiple records -- for example, pulling all SKUs or titles from a list of items. It supports dot notation for accessing nested fields.

Syntax

{{pluck array "property"}}

array -- The array of objects to extract values from. Required.

property -- The property name to extract from each element. Required. Wrap in double quotes. Supports dot notation for nested fields (e.g. "data.title", "order.customer.name").

Examples

Extract a top-level property from each object

{{pluck record.products "sku"}}

Input:

{
  "record": {
    "products": [
      { "sku": "A001", "price": 20 },
      { "sku": "A002", "price": 30 },
      { "sku": "A003", "price": 25 }
    ]
  }
}

Output: ["A001", "A002", "A003"]

Extract a nested property using dot notation

{{pluck record.items "data.title"}}

Input:

{
  "record": {
    "items": [
      { "data": { "title": "Introduction to Handlebars", "category": "Tutorial" } },
      { "data": { "title": "Advanced Template Logic", "category": "Guide" } },
      { "data": { "title": "Using Helpers Effectively", "category": "Best Practices" } }
    ]
  }
}

Output: ["Introduction to Handlebars", "Advanced Template Logic", "Using Helpers Effectively"]

Dot notation traverses nested objects: "data.title" resolves to the title field inside each data object.

Usage notes

  • Wrap the property argument in double quotes.
  • Use dot notation to access deeply nested values (e.g. "order.customer.name").
  • If a property doesn't exist on an element, pluck returns null for that position in the output array.
  • Combine with join to convert the resulting array to a delimited string, or with unique to remove duplicate values.