1
0
mirror of https://github.com/gohugoio/hugo.git synced 2024-05-11 05:54:58 +00:00
Files
gohugoio-hugo/docs/content/en/functions/NumFmt.md
2019-10-21 10:22:28 +02:00

1.2 KiB

title, description, godocref, workson, date, publishdate, lastmod, categories, keywords, menu, toc, signature, workson, hugoversion, relatedfuncs, deprecated, draft, aliases, comments
title description godocref workson date publishdate lastmod categories keywords menu toc signature workson hugoversion relatedfuncs deprecated draft aliases comments
lang.NumFmt Formats a number with a given precision using the requested `negative`, `decimal`, and `grouping` options. The `options` parameter is a string consisting of `<negative> <decimal> <grouping>`.
2017-02-01 2017-02-01 2017-08-21
functions
numbers
docs
parent
functions
false
lang.NumFmt PRECISION NUMBER [OPTIONS [DELIMITER]]
false false

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.

{{ 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 6 -12345.6789 "- ." }} → -12345.678900
{{ lang.NumFmt 6 -12345.6789 "-|.| " "|" }} → -1 2345.678900
{{ -98765.4321 | lang.NumFmt 2 }} → -98,765.43