Add human file size partial.
This commit is contained in:
@@ -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 -}}
|
||||||
Reference in New Issue
Block a user