Advertisement
Not a member of Pastebin yet?
Sign Up,
it unlocks many cool features!
- {{ $ordinal := "th" }} {{/* default ordinal value in most cases is set here */}}
- {{ $n := (parseArgs 1 "" (carg "int" "int") ).Get 0 }}
- {{ $x := div (toInt (mod $n 100) ) 10 }}
- {{ $y := toInt (mod $n 10) }}
- {{ if eq $x 1 }} {{/* ordinal remains unchanged so this is "break" */}}
- {{ else if eq $y 1 }} {{ $ordinal = "st" }}
- {{ else if eq $y 2 }} {{ $ordinal = "nd" }}
- {{ else if eq $y 3 }} {{ $ordinal = "rd" }}
- {{ end }}
- {{ joinStr "'" $n $ordinal }}
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement