mirror of
https://github.com/gohugoio/hugo.git
synced 2025-08-19 21:21:39 +02:00
Merge commit '9b0050e9aabe4be65c78ccf292a348f309d50ccd' as 'docs'
``` git subtree add --prefix=docs/ https://github.com/gohugoio/hugoDocs.git master --squash ``` Closes #11925
This commit is contained in:
34
docs/content/en/functions/lang/FormatNumberCustom.md
Normal file
34
docs/content/en/functions/lang/FormatNumberCustom.md
Normal file
@@ -0,0 +1,34 @@
|
||||
---
|
||||
title: lang.FormatNumberCustom
|
||||
description: Returns a numeric representation of a number with the given precision using negative, decimal, and grouping options.
|
||||
categories: []
|
||||
keywords: []
|
||||
action:
|
||||
aliases: []
|
||||
related:
|
||||
- functions/lang/FormatAccounting
|
||||
- functions/lang/FormatCurrency
|
||||
- functions/lang/FormatNumber
|
||||
- functions/lang/FormatPercent
|
||||
returnType: string
|
||||
signatures: ['lang.FormatNumberCustom PRECISION NUMBER [OPTIONS...]']
|
||||
aliases: ['/functions/numfmt/']
|
||||
---
|
||||
|
||||
This function 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.
|
||||
|
||||
For a simpler function that adapts to the current language, see [`lang.FormatNumber`].
|
||||
|
||||
```go-html-template
|
||||
{{ lang.FormatNumberCustom 2 12345.6789 }} → 12,345.68
|
||||
{{ 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
|
||||
```
|
||||
|
||||
{{% include "functions/_common/locales.md" %}}
|
||||
|
||||
[`lang.FormatNumber`]: /functions/lang/formatnumber
|
Reference in New Issue
Block a user