Numeric Helpers API reference for numeric template helpers hash Guide

Numeric Helpers

Numeric helpers provide utilities for working with numbers in templates.

Functions

numberFromIndex

Returns the index plus one, useful for human-readable numbering.

Template Syntax

{numberFromIndex @index}

Parameters

NameTypeDescription
anumberThe index value

Returns

number - The index plus one.

Example

{#each items}
Item {numberFromIndex @index}: {this}
{/each}

maybePlural

Adds a plural suffix if the value is not 1.

Template Syntax

{maybePlural itemCount 's'}

Parameters

NameTypeDefaultDescription
valuenumberThe count to check
pluralstring’s’The plural suffix to add

Returns

string - The plural suffix if the value is not 1, otherwise an empty string.

Example

<p>You have {itemCount} item{maybePlural itemCount} in your cart.</p>