From 423b8f2fb834139cf31514b14b1c1bf28e43b384 Mon Sep 17 00:00:00 2001 From: "Eli W. Hunter" Date: Sat, 14 Mar 2020 10:43:10 -0400 Subject: Add render template hooks for headings This commit also * Renames previous types to be non-specific. (e.g. hookedRenderer rather than linkRenderer) Resolves #6713 --- hugolib/site.go | 12 +++++++++--- 1 file changed, 9 insertions(+), 3 deletions(-) (limited to 'hugolib/site.go') diff --git a/hugolib/site.go b/hugolib/site.go index 5688b5fac..34671443e 100644 --- a/hugolib/site.go +++ b/hugolib/site.go @@ -1650,14 +1650,20 @@ var infoOnMissingLayout = map[string]bool{ "404": true, } -type contentLinkRenderer struct { +// hookRenderer is the canonical implementation of all hooks.ITEMRenderer, +// where ITEM is the thing being hooked. +type hookRenderer struct { templateHandler tpl.TemplateHandler identity.Provider templ tpl.Template } -func (r contentLinkRenderer) Render(w io.Writer, ctx hooks.LinkContext) error { - return r.templateHandler.Execute(r.templ, w, ctx) +func (hr hookRenderer) RenderLink(w io.Writer, ctx hooks.LinkContext) error { + return hr.templateHandler.Execute(hr.templ, w, ctx) +} + +func (hr hookRenderer) RenderHeading(w io.Writer, ctx hooks.HeadingContext) error { + return hr.templateHandler.Execute(hr.templ, w, ctx) } func (s *Site) renderForTemplate(name, outputFormat string, d interface{}, w io.Writer, templ tpl.Template) (err error) { -- cgit v1.2.3