Feat: add new partial function format-number

This commit is contained in:
Cell
2024-04-10 11:04:44 +08:00
parent 773a8a7eb9
commit d379911220
@@ -0,0 +1,12 @@
{{- /* How to use */ -}}
{{- /* partial "function/format-number" (dict "PRECISION" 2 "NUMBER" 5201314 */ -}}
{{- $number := .NUMBER -}}
{{- $precision := .PRECISION | default 1 -}}
{{- with $number -}}
{{- if ge . 1000 -}}
{{- $number = printf "%vk" (lang.FormatNumberCustom $precision (div . 1000.0) "- .") -}}
{{ printf "%v" $number }}
{{- end -}}
{{- end -}}
{{- return $number -}}