Skip to content

Commit

Permalink
refactor: left overs forgotten added
Browse files Browse the repository at this point in the history
  • Loading branch information
dd84ai committed Jan 3, 2024
1 parent 506308b commit 19c36e6
Show file tree
Hide file tree
Showing 2 changed files with 5 additions and 2 deletions.
5 changes: 3 additions & 2 deletions goutils/utils/template.go
Original file line number Diff line number Diff line change
Expand Up @@ -6,6 +6,7 @@ import (
"text/template"

"github.com/darklab8/darklab_goutils/goutils/utils/utils_logus"
"github.com/darklab8/darklab_goutils/goutils/utils/utils_types"
)

func TmpRender(templateRef *template.Template, data interface{}) string {
Expand All @@ -15,14 +16,14 @@ func TmpRender(templateRef *template.Template, data interface{}) string {
return header.String()
}

func TmpInit(content string) *template.Template {
func TmpInit(content utils_types.TemplateExpression) *template.Template {
funcs := map[string]any{
"contains": strings.Contains,
"hasPrefix": strings.HasPrefix,
"hasSuffix": strings.HasSuffix}

var err error
templateRef, err := template.New("test").Funcs(funcs).Parse(content)
templateRef, err := template.New("test").Funcs(funcs).Parse(string(content))
utils_logus.Log.CheckFatal(err, "failed to init template")
return templateRef
}
2 changes: 2 additions & 0 deletions goutils/utils/utils_types/types.go
Original file line number Diff line number Diff line change
Expand Up @@ -5,3 +5,5 @@ type FilePath string
func (f FilePath) ToString() string { return string(f) }

type RegExp string

type TemplateExpression string

0 comments on commit 19c36e6

Please sign in to comment.