Home

tmpl @6ffc50dc06e46255334863e33156b8e0e82fafcb - refs - log -
-
https://git.jolheiser.com/tmpl.git
Template automation
tmpl / registry / helper.go
- raw
 1
 2
 3
 4
 5
 6
 7
 8
 9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
package registry

import (
	"os"
	"path/filepath"
	"strings"
	"time"

	"github.com/huandu/xstrings"
)

var funcMap = map[string]interface{}{

	// String conversions
	"upper":  strings.ToUpper,
	"lower":  strings.ToLower,
	"title":  strings.Title,
	"snake":  xstrings.ToSnakeCase,
	"kebab":  xstrings.ToKebabCase,
	"pascal": xstrings.ToCamelCase,
	"camel": func(in string) string {
		return xstrings.FirstRuneToLower(xstrings.ToCamelCase(in))
	},

	// Other
	"env": os.Getenv,
	"sep": func() string {
		return string(filepath.Separator)
	},
	"time": func(fmt string) string {
		return time.Now().Format(fmt)
	},
}