]> git.maquefel.me Git - brevno-suite/hugo/commitdiff
tpl/lang: document delimiter option for FormatNumberCustom
authorJoe Mooring <joe.mooring@veriphor.com>
Mon, 20 Mar 2023 16:39:33 +0000 (09:39 -0700)
committerBjørn Erik Pedersen <bjorn.erik.pedersen@gmail.com>
Wed, 17 May 2023 21:35:43 +0000 (23:35 +0200)
Closes gohugoio/hugoDocs#1760

tpl/lang/init.go
tpl/lang/lang.go

index 4591800a01fcad3e4cfde5b5b11cc482305e5090..cad4eee0973b86c0992ff62a6e08a8a59de65a9b 100644 (file)
@@ -72,6 +72,7 @@ func init() {
                                {`{{ lang.FormatNumberCustom 2 12345.6789 "- , ." }}`, `12.345,68`},
                                {`{{ lang.FormatNumberCustom 6 -12345.6789 "- ." }}`, `-12345.678900`},
                                {`{{ lang.FormatNumberCustom 0 -12345.6789 "- . ," }}`, `-12,346`},
+                               {`{{ lang.FormatNumberCustom 0 -12345.6789 "-|.| " "|" }}`, `-12 346`},
                                {`{{ -98765.4321 | lang.FormatNumberCustom 2 }}`, `-98,765.43`},
                        },
                )
index d2de243d6c180b851521a4aa1d2a75b527552ab8..814191c3ad31c91e2ded116f5b28d1123244396c 100644 (file)
@@ -133,10 +133,10 @@ func (ns *Namespace) castPrecisionNumber(precision, number any) (uint64, float64
        return p, n, nil
 }
 
-// FormatNumberCustom formats a number with the given precision using the
-// negative, decimal, and grouping options.  The `options`
-// parameter is a string consisting of `<negative> <decimal> <grouping>`.  The
-// default `options` value is `- . ,`.
+// FormatNumberCustom formats a number with the given precision. The first
+// options parameter is a space-delimited string of characters to represent
+// negativity, the decimal point, and grouping. The default value is `- . ,`.
+// The second options parameter defines an alternate delimiting character.
 //
 // Note that numbers are rounded up at 5 or greater.
 // So, with precision set to 0, 1.5 becomes `2`, and 1.4 becomes `1`.