Skip to content

Format

This page contains information about the template functions related to formatting:

  • FormatBytesSI( num: Number ): string → Formats the given number as a SI byte string, eg. 7896759 as 7,897 MB;
  • FormatBytesIEC( num: Number ): string → Formats the given number as a IEC byte string, eg. 7896759 as 7.531 MB;
  • FormatFloat( num: Float, format: string ): string → Formats the given float as a string, using the format given below;
  • FormatInteger( num: Integer, format: string ): string → Formats the given integer as a string, using format given below;
  • FormatOrdinal( num: int ): string → Formats the given integer as an ordinal, eg. 3 as 3rd;
  • FormatAny( format: string, ...args: any): string → Formats the given string, using the standard fmt.Sprintf.

Format of Integer and Float formatting functions

##,###.##

Where:

  • The first separator, in the example case the comma, is the thousands separator;
  • The second separator is the decimal separator (only applies to floats);
  • The final two cardinals, are the number of decimal points to keep (only applies to floats).

If you do not want to use a thousands separator, you can use something like:

  • ###.## → For floats;
  • ### → For integers.