providers: Add path functions to supplement sprig's

This commit is contained in:
2024-12-07 02:13:06 -05:00
parent 30323c0d59
commit e7e31f0e60
2 changed files with 31 additions and 0 deletions

29
providers/path/path.go Normal file
View File

@@ -0,0 +1,29 @@
package path
import "path"
// import "strings"
import "html/template"
import "git.tebibyte.media/sashakoshka/step"
var _ step.FuncProvider = new(Provider)
// Provider provides path functions.
type Provider struct {
}
// FuncMap fulfills the step.FuncProvider interface.
func (this *Provider) FuncMap () template.FuncMap {
return template.FuncMap {
"joinPaths": funcJoinPaths,
"osJoinPaths": funcOSJoinPaths,
}
}
func funcJoinPaths (left, right string) string {
return path.Join(left, right)
}
func funcOSJoinPaths (left, right string) string {
return path.Join(left, right)
}