summaryrefslogtreecommitdiffstats
path: root/hugolib/site.go
diff options
context:
space:
mode:
authorEli W. Hunter <elihunter173@gmail.com>2020-03-14 10:43:10 -0400
committerBjørn Erik Pedersen <bjorn.erik.pedersen@gmail.com>2020-05-15 21:12:43 +0200
commit423b8f2fb834139cf31514b14b1c1bf28e43b384 (patch)
treedcd2d3c2dfcc5e2960056462c2d048906b1acc55 /hugolib/site.go
parent991934497e88dcd4134a369a213bb5072c51c139 (diff)
Add render template hooks for headings
This commit also * Renames previous types to be non-specific. (e.g. hookedRenderer rather than linkRenderer) Resolves #6713
Diffstat (limited to 'hugolib/site.go')
-rw-r--r--hugolib/site.go12
1 files changed, 9 insertions, 3 deletions
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) {