Articles in this section

addCommas helper

The addCommas helper formats a number by inserting commas as thousands separators (e.g. 1234567 → 1,234,567). Use it to improve readability of large numbers such as counts, totals, and financial values in output templates.

Syntax

{{addCommas value}}

value -- The number to format. Required. Accepts integers and floating-point numbers. Returns an empty string for null, undefined, or non-numeric values.

Examples

Format large integers

{{addCommas record.stats.views}} {{addCommas record.stats.downloads}}

Input:

{
  "record": {
    "stats": {
      "views": 1234567,
      "downloads": 987654321
    }
  }
}

Output: 1,234,567 987,654,321

Combine with static text

Total views: {{addCommas record.views}}

Input:

{ "record": { "views": 1543220 } }

Output: Total views: 1,543,220

Usage notes

  • Works with both integers and floating-point numbers.
  • Returns an empty string for null, undefined, or non-numeric input -- no error is thrown.
  • addCommas formats numbers for display only. Don't use the output as input to math helpers such as add or sum -- the commas will cause those helpers to fail.