mirror of
https://github.com/tiennm99/hugoDocs.git
synced 2026-10-14 18:18:37 +00:00
tpl: Add a delimiter parameter to lang.NumFmt
The original implementation of NumFmt did not take into account that the options delimiter (a space) could be a valid option. Adding a delim parameter seems like the simplest, safest, and most flexible way to solve this oversight in a backwards-compatible way. Fixes #5260
This commit is contained in:
1 parent
d758ef94a7
commit
fd1cde5ea2
1 file changed
+5
-2
@@ -12,7 +12,7 @@ menu:
|
|||||||
docs:
|
docs:
|
||||||
parent: "functions"
|
parent: "functions"
|
||||||
toc: false
|
toc: false
|
||||||
signature: ["lang.NumFmt PRECISION NUMBER [OPTIONS]"]
|
signature: ["lang.NumFmt PRECISION NUMBER [OPTIONS [DELIMITER]]"]
|
||||||
workson: []
|
workson: []
|
||||||
hugoversion:
|
hugoversion:
|
||||||
relatedfuncs: []
|
relatedfuncs: []
|
||||||
@@ -22,7 +22,9 @@ aliases: []
|
|||||||
comments:
|
comments:
|
||||||
---
|
---
|
||||||
|
|
||||||
The default options value is `- . ,`.
|
The default options value is `- . ,`. The default delimiter within the options
|
||||||
|
value is a space. If you need to use a space as one of the options, set a
|
||||||
|
custom delimiter.
|
||||||
|
|
||||||
Numbers greater than or equal to 5 are rounded up. For example, if precision is set to `0`, `1.5` becomes `2`, and `1.4` becomes `1`.
|
Numbers greater than or equal to 5 are rounded up. For example, if precision is set to `0`, `1.5` becomes `2`, and `1.4` becomes `1`.
|
||||||
|
|
||||||
@@ -31,5 +33,6 @@ Numbers greater than or equal to 5 are rounded up. For example, if precision is
|
|||||||
{{ lang.NumFmt 2 12345.6789 "- , ." }} → 12.345,68
|
{{ lang.NumFmt 2 12345.6789 "- , ." }} → 12.345,68
|
||||||
{{ lang.NumFmt 0 -12345.6789 "- . ," }} → -12,346
|
{{ lang.NumFmt 0 -12345.6789 "- . ," }} → -12,346
|
||||||
{{ lang.NumFmt 6 -12345.6789 "- ." }} → -12345.678900
|
{{ lang.NumFmt 6 -12345.6789 "- ." }} → -12345.678900
|
||||||
|
{{ lang.NumFmt 6 -12345.6789 "-|.| " "|" }} → -1 2345.678900
|
||||||
{{ -98765.4321 | lang.NumFmt 2 }} → -98,765.43
|
{{ -98765.4321 | lang.NumFmt 2 }} → -98,765.43
|
||||||
```
|
```
|
||||||
Reference in new issue
Block a user