
ctrl+k
Enter a search term above to see results...
Enter a search term above to see results...
Numeric helpers provide utilities for working with numbers in templates.
Returns the index plus one, useful for human-readable numbering.
{numberFromIndex index}
Name | Type | Description |
---|---|---|
a | number | The index value |
number
- The index plus one.
{#each items} Item {numberFromIndex index}: {this}{/each}
Adds a plural suffix if the value is not 1.
{maybePlural itemCount 's'}
Name | Type | Default | Description |
---|---|---|---|
value | number | The count to check | |
plural | string | ’s’ | The plural suffix to add |
string
- The plural suffix if the value is not 1, otherwise an empty string.
<p>You have {itemCount} item{maybePlural itemCount} in your cart.</p>
Rounds a number to a specified number of decimal places.
{roundNumber numberToRound precision}
Name | Type | Description |
---|---|---|
number | number | The number to round |
precision | number | Number of decimal places |
number
- The rounded number.
<p>Average score: {roundNumber score 1}</p><p>Price: ${roundNumber price 2}</p>
Alias for roundNumber
. Rounds a number to a specified number of decimal places.
{round numberToRound precision}
Name | Type | Description |
---|---|---|
number | number | The number to round |
precision | number | Number of decimal places |
number
- The rounded number.
<p>Temperature: {round temperature 1}°C</p>
Rounds a number to a specified number of decimal places using decimal rounding.
{roundDecimal numberToRound precision}
Name | Type | Description |
---|---|---|
number | number | The number to round |
precision | number | Number of decimal places |
number
- The rounded number using decimal rounding.
<p>Precise measurement: {roundDecimal measurement 3}mm</p>