tknx
1
Let’s say I have numbers in front matter formatted as “01.010” and “01.0105”
I want it to appear on the website the same way.
- Minimum of 3 decimal places but more if they are there and
- Always two digits on the whole number side with a leading zero.
{{ with .Params.foo }}
{{ $precision := math.Max 3 (sub (len (path.Ext .)) 1) | int }}
{{ $width := add 3 $precision | int }}
{{ printf "%0*.*f" $width $precision (float .) }}
{{ end }}
2 Likes
system
Closed
3
This topic was automatically closed 2 days after the last reply. New replies are no longer allowed.