Articles in this section

ordinalize helper

Converts a number into its ordinal string form (e.g., 1 → 1st, 2 → 2nd, 3 → 3rd). It correctly handles special cases such as 11, 12, and 13, which use the th suffix.

Usage

{{ordinalize value}}
  • value (required): number or numeric string to ordinalize

Examples

  1. Ordinalize basic numbers

    {{ordinalize record.a}}
    {{ordinalize record.b}}
    {{ordinalize record.c}}
    {{ordinalize record.d}}
    {{ordinalize record.e}}

    Input:

     { "record": { "a": 1, "b": 2, "c": 3, "d": 11, "e": 22 } }
    

    Output:

    1st
    2nd
    3rd
    11th
    22nd
    
  2. Ordinalize values from record fields

    {{ordinalize record.rank}}
    

    Input:

    { "record": { "rank": 4 } }
    

    Output:

    4th
    

Tip

  • Works with both numbers and numeric strings (e.g., "5"5th).

  • Will not work with negatives, floats, or text strings.

  • The helper ensures correct suffixes (st, nd, rd, th) even for tricky numbers like 11, 12, and 13.

  • Useful for displaying ranks, steps, or ordered positions in a user-friendly format.