diff --git a/VERSION b/VERSION index f0bb29e..88c5fb8 100644 --- a/VERSION +++ b/VERSION @@ -1 +1 @@ -1.3.0 +1.4.0 diff --git a/go.mod b/go.mod index 1b649af..d588023 100644 --- a/go.mod +++ b/go.mod @@ -1,8 +1,6 @@ module zehd-frontend -go 1.21.3 - -toolchain go1.21.4 +go 1.21.5 require ( github.com/aws/smithy-go v1.12.1 @@ -15,4 +13,7 @@ require ( github.com/russross/blackfriday/v2 v2.1.0 ) -require golang.org/x/exp v0.0.0-20231108232855-2478ac86f678 // indirect +require ( + github.com/APoniatowski/funcmytemplate v0.0.1 // indirect + golang.org/x/exp v0.0.0-20231108232855-2478ac86f678 // indirect +) diff --git a/go.sum b/go.sum index c491a8f..fb02754 100644 --- a/go.sum +++ b/go.sum @@ -1,5 +1,7 @@ github.com/APoniatowski/boillog v1.1.0 h1:jceyfIZCuGSn4e3Rlo0JOXK6C46Gce6MpITowkbeX1E= github.com/APoniatowski/boillog v1.1.0/go.mod h1:c7PpNRmlFv6tFVu9ogT/i1VwGsOeWRY8gRX14yHYpRQ= +github.com/APoniatowski/funcmytemplate v0.0.1 h1:iuMga0N5U4umc28iucvy0oPFlW7JCyrT8l7Z9xMsvwU= +github.com/APoniatowski/funcmytemplate v0.0.1/go.mod h1:d6IWMKOFbDyEPb46miTukA2c/4yHFahDC9wm5e/6EOE= github.com/aws/smithy-go v1.12.1 h1:yQRC55aXN/y1W10HgwHle01DRuV9Dpf31iGkotjt3Ag= github.com/aws/smithy-go v1.12.1/go.mod h1:Tg+OJXh4MB2R/uN61Ko2f6hTZwB/ZYGOtib8J3gBHzA= github.com/davecgh/go-spew v1.1.0/go.mod h1:J7Y8YcW2NihsgmVo/mv3lAwl/skON4iLHjSsI+c5H38= diff --git a/pkg/caching/cachingHelpers.go b/pkg/caching/cachingHelpers.go index 98ab5fa..a1e9dbc 100644 --- a/pkg/caching/cachingHelpers.go +++ b/pkg/caching/cachingHelpers.go @@ -7,6 +7,7 @@ import ( "time" "github.com/APoniatowski/boillog" + "github.com/APoniatowski/funcmytemplate" "github.com/gomarkdown/markdown" "github.com/russross/blackfriday/v2" @@ -15,13 +16,13 @@ import ( // pageBuilder Private helper function that builds HTML/goHTML pages and returns the templates func pageBuilder(templatePath, layoutPath string) (*template.Template, error) { defer boillog.TrackTime("page-builder", time.Now()) - funcmytemplate := template.FuncMap{} // TODO: add funcmytemplate here later + funcmytemplates := funcmytemplate.Add() templates := template.New("") _, err := os.Stat(layoutPath) if err != nil || !os.IsNotExist(err) { - templates, err = templates.Funcs(funcmytemplate).ParseFiles(templatePath) + templates, err = templates.Funcs(funcmytemplates).ParseFiles(templatePath) } else { - templates, err = templates.Funcs(funcmytemplate).ParseFiles(layoutPath, templatePath) + templates, err = templates.Funcs(funcmytemplates).ParseFiles(layoutPath, templatePath) } if err != nil { return nil, err @@ -33,7 +34,7 @@ func pageBuilder(templatePath, layoutPath string) (*template.Template, error) { func convertOrgToTemplate(orgPath, layoutPath string) (*template.Template, error) { defer boillog.TrackTime("org-converter", time.Now()) var err error - funcmytemplate := template.FuncMap{} // TODO: add funcmytemplate here later + funcmytemplates := funcmytemplate.Add() templates := template.New("") _, notFoundErr := os.Stat(layoutPath) if notFoundErr != nil { @@ -44,7 +45,7 @@ func convertOrgToTemplate(orgPath, layoutPath string) (*template.Template, error htmlBytes := blackfriday.Run(orgBytes) html := string(htmlBytes) html = fmt.Sprintf(`{{define "org"}}%s{{end}}`, html) - templates, err = templates.Funcs(funcmytemplate).Parse(html) + templates, err = templates.Funcs(funcmytemplates).Parse(html) if err != nil { return nil, err } @@ -56,8 +57,8 @@ func convertOrgToTemplate(orgPath, layoutPath string) (*template.Template, error htmlBytes := blackfriday.Run(orgBytes) html := string(htmlBytes) html = fmt.Sprintf(`{{define "org"}}%s{{end}}`, html) - templates, err = templates.Funcs(funcmytemplate).ParseFiles(layoutPath) - templates, err = templates.Funcs(funcmytemplate).Parse(html) + templates, err = templates.Funcs(funcmytemplates).ParseFiles(layoutPath) + templates, err = templates.Funcs(funcmytemplates).Parse(html) } if err != nil { return nil, err @@ -69,7 +70,7 @@ func convertOrgToTemplate(orgPath, layoutPath string) (*template.Template, error func convertMarkdownToTemplate(markdownPath, layoutPath string) (*template.Template, error) { defer boillog.TrackTime("md-converter", time.Now()) var err error - funcmytemplate := template.FuncMap{} // TODO: add funcmytemplate here later + funcmytemplates := funcmytemplate.Add() templates := template.New("") _, notFoundErr := os.Stat(layoutPath) if notFoundErr != nil { @@ -79,7 +80,7 @@ func convertMarkdownToTemplate(markdownPath, layoutPath string) (*template.Templ } html := string(markdown.ToHTML(markdownBytes, nil, nil)) html = fmt.Sprintf(`{{define "markdown"}}%s{{end}}`, html) - templates, err = templates.Funcs(funcmytemplate).Parse(html) + templates, err = templates.Funcs(funcmytemplates).Parse(html) if err != nil { return nil, err } @@ -90,8 +91,8 @@ func convertMarkdownToTemplate(markdownPath, layoutPath string) (*template.Templ } html := string(markdown.ToHTML(markdownBytes, nil, nil)) html = fmt.Sprintf(`{{define "markdown"}}%s{{end}}`, html) - templates, err = templates.Funcs(funcmytemplate).ParseFiles(layoutPath) - templates, err = templates.Funcs(funcmytemplate).Parse(html) + templates, err = templates.Funcs(funcmytemplates).ParseFiles(layoutPath) + templates, err = templates.Funcs(funcmytemplates).Parse(html) } if err != nil { return nil, err