From dd62d11b407b1de633835d2575cbedede8cb3ad4 Mon Sep 17 00:00:00 2001 From: JT Archie Date: Tue, 23 Jan 2024 19:27:25 -0700 Subject: [PATCH] add funcs in layout too --- render.go | 12 +++++++----- 1 file changed, 7 insertions(+), 5 deletions(-) diff --git a/render.go b/render.go index 140e768..b8d06e4 100644 --- a/render.go +++ b/render.go @@ -20,6 +20,7 @@ import ( "github.com/microcosm-cc/bluemonday" cp "github.com/otiai10/copy" "github.com/sabloger/sitemap-generator/smg" + "github.com/samber/lo" "github.com/tdewolff/minify" mHTML "github.com/tdewolff/minify/html" "github.com/yuin/goldmark" @@ -315,11 +316,12 @@ func (r *Render) renderDocument(doc *Doc, funcMap template.FuncMap, layout *temp layoutWriter := &bytes.Buffer{} - err = layout.Execute(layoutWriter, map[string]any{ - "Doc": doc, - - "RenderedPage": renderedMarkdown, - }) + err = layout.Execute(layoutWriter, lo.Assign( + funcMap, + map[string]any{ + "Doc": doc, + "RenderedPage": renderedMarkdown, + })) if err != nil { return fmt.Errorf("could not render layout template (%s): %w", doc.Filename(), err) }