Add 'pctOf' and 'fit' template functions

This commit is contained in:
Adriano
2019-03-18 08:39:38 -04:00
committed by Cory Bennett
parent 8ede63c37e
commit 997b6e1f24
+6
View File
@@ -76,6 +76,9 @@ func TemplateProcessor() *template.Template {
} }
return out return out
}, },
"fit": func(size int, content string) string {
return fmt.Sprintf(fmt.Sprintf("%%-%d.%ds", size, size), content)
},
"shellquote": func(content string) string { "shellquote": func(content string) string {
return shellquote.Join(content) return shellquote.Join(content)
}, },
@@ -106,6 +109,9 @@ func TemplateProcessor() *template.Template {
} }
return 120 return 120
}, },
"pctOf": func(size, percent int) int {
return int(float32(size) * (float32(percent) / 100))
},
"sub": func(a, b int) int { "sub": func(a, b int) int {
return a - b return a - b
}, },