Files
kollegen-hugo/layouts/partials/func/NumberFormatter.html
T
2020-10-13 21:44:56 +02:00

21 lines
639 B
HTML

{{/*
NumberFormatter
This partial exchanges the characters for thousends and decimals for the give integer,
used in Germany.
Use this for intergers and floats instead of Hugo's lang.NumFmt and float which are
not language specific.
Example
{{ partial "func/NumberFormatter.html" ( dict "number" 123456789.1234 "precision" 1 }}
will return 123.456.789,1
@return String with integer
*/}}
{{ $ret := strings.Replace ( lang.NumFmt .precision .number "- . ," ) "," "t" }}
{{ $ret = strings.Replace $ret "." "d" }}
{{ $ret = strings.Replace $ret "d" "," }}
{{ strings.Replace $ret "t" "." }}