From 19c36e61baa7854e4e17862e032b3392aa788de5 Mon Sep 17 00:00:00 2001 From: dd84ai Date: Wed, 3 Jan 2024 06:03:08 +0100 Subject: [PATCH] refactor: left overs forgotten added --- goutils/utils/template.go | 5 +++-- goutils/utils/utils_types/types.go | 2 ++ 2 files changed, 5 insertions(+), 2 deletions(-) diff --git a/goutils/utils/template.go b/goutils/utils/template.go index f1c49a1..36c665c 100644 --- a/goutils/utils/template.go +++ b/goutils/utils/template.go @@ -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 { @@ -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 } diff --git a/goutils/utils/utils_types/types.go b/goutils/utils/utils_types/types.go index 77b62f2..bc077a3 100644 --- a/goutils/utils/utils_types/types.go +++ b/goutils/utils/utils_types/types.go @@ -5,3 +5,5 @@ type FilePath string func (f FilePath) ToString() string { return string(f) } type RegExp string + +type TemplateExpression string