ctrl+k
Enter a search term above to see results...
Enter a search term above to see results...
Array helpers provide utilities for working with arrays in templates.
Gets the length of an array or array-like object.
{count itemsArray}| Name | Type | Description |
|---|---|---|
| array | array | The array to count |
number - The length of the array, or 0 if null/undefined.
<p>You have {count notifications} notifications</p>Gets the first element of an array.
{first itemsArray}| Name | Type | Description |
|---|---|---|
| array | array | The array to get the first element from |
any - The first element of the array, or undefined if empty.
<p>Primary category: <b>{first categories}</b></p>Gets the last element of an array.
{last itemsArray}| Name | Type | Description |
|---|---|---|
| array | array | The array to get the last element from |
any - The last element of the array, or undefined if empty.
<p>Most recent item: <b>{last recentItems}</b></p>Joins array elements with a delimiter.
{join itemsArray ', ' true}| Name | Type | Default | Description |
|---|---|---|---|
| array | array | [] | The array to join |
| delimiter | string | ’ ‘ | The delimiter to use |
| spaceAfter | boolean | false | Whether to add a space after the joined string |
string - The joined string.
<p>Categories: {join categories ', ' false}</p>Joins array elements with commas.
{joinComma itemsArray true false}| Name | Type | Default | Description |
|---|---|---|---|
| array | array | [] | The array to join |
| oxford | boolean | false | Whether to use Oxford comma |
| quotes | boolean | false | Whether to wrap items in quotes |
string - The comma-joined string.
<p>This product comes in {joinComma colors true true}.</p>Returns an array with a range of numbers.
{#each number in range 1 6} {number}{/each}| Name | Type | Default | Description |
|---|---|---|---|
| start | number | The start of the range | |
| stop | number | The end of the range | |
| step | number | 1 | The step between numbers |
array - An array containing the range of numbers.
<select name="birthyear"> {#each range 1900 2024} <option value="{this}">{this}</option> {/each}</select>