Add human file size partial.

This commit is contained in:
2026-06-24 16:10:17 +02:00
parent bf6ae71511
commit 8d367dfa79
+7
View File
@@ -0,0 +1,7 @@
{{/* Call this with a resource's content e.g., partial "human_file_size" .Content */}}
{{- $bytes := len . -}}
{{- $kb := div $bytes 1024 -}}
{{- $mb := div $kb 1024 -}}
{{- if ge $mb 1 -}}{{- $mb -}} MB
{{- else if ge $kb 1 -}}{{- $kb -}} KB
{{- else -}}{{- $bytes -}} B{{- end -}}