Articles in this section

unique helper

The unique helper returns a new array with all duplicate values removed. Use it with #each or other rendering helpers to process or display only distinct values.

Usage

{{unique array}}
  • array (required): array to deduplicate

Examples

Remove duplicates from a string array

{{#each (unique record.tags)}}{{this}}{{#unless @last}},{{/unless}}{{/each}}

Input:

{ "record": { "tags": ["a", "a", "c", "b", "e", "e"] } }

Output:

a,c,b,e,

Use with nested data

{{#each (unique record.categories)}}
  {{this}}
{{/each}}

Input:

{ "record": { "categories": ["A","B","A","C","B"] } }

Output:

A
B
C

Tip

  • Preserves the original order of first occurrences.

  • Works only for arrays of primitive values (strings, numbers, booleans).

  • Use this helper to eliminate duplicates before iterating or combining results from multiple data sources.