mirror of
https://github.com/hanzokms/cli.git
synced 2026-10-30 20:30:00 +00:00
32 lines
565 B
Go
32 lines
565 B
Go
package templates
|
|
|
|
import (
|
|
"embed"
|
|
"text/template"
|
|
|
|
"github.com/Masterminds/sprig/v3"
|
|
)
|
|
|
|
//go:embed *.tmpl
|
|
var TemplatesFS embed.FS
|
|
|
|
func CompileTemplateFunctions(customFunctions template.FuncMap) template.FuncMap {
|
|
|
|
templates := customFunctions
|
|
|
|
sprigFuncs := sprig.TxtFuncMap()
|
|
// removed for security reasons
|
|
delete(sprigFuncs, "env")
|
|
delete(sprigFuncs, "expandenv")
|
|
|
|
for k, v := range sprigFuncs {
|
|
// make sure we aren't overwriting any of our own functions
|
|
_, exists := templates[k]
|
|
if !exists {
|
|
templates[k] = v
|
|
}
|
|
}
|
|
|
|
return templates
|
|
}
|