summaryrefslogtreecommitdiffstats
diff options
context:
space:
mode:
authorJoe Mooring <joe.mooring@veriphor.com>2023-03-20 09:39:33 -0700
committerBjørn Erik Pedersen <bjorn.erik.pedersen@gmail.com>2023-05-17 23:35:43 +0200
commit1155bbca9d4cdf42e9b4a2d0351fd5be0aa8ec08 (patch)
tree8ae851b792e2110a5b8e982c0f5bde08427b4e19
parent86b2a27438410eef0e1169fc201b3d1cf6e6ca62 (diff)
tpl/lang: document delimiter option for FormatNumberCustom
Closes gohugoio/hugoDocs#1760
-rw-r--r--tpl/lang/init.go1
-rw-r--r--tpl/lang/lang.go8
2 files changed, 5 insertions, 4 deletions
diff --git a/tpl/lang/init.go b/tpl/lang/init.go
index 4591800a0..cad4eee09 100644
--- a/tpl/lang/init.go
+++ b/tpl/lang/init.go
@@ -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`},
},
)
diff --git a/tpl/lang/lang.go b/tpl/lang/lang.go
index d2de243d6..814191c3a 100644
--- a/tpl/lang/lang.go
+++ b/tpl/lang/lang.go
@@ -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`.