Add render template hooks for headings

This commit also

* Renames previous types to be non-specific. (e.g. hookedRenderer rather
  than linkRenderer)

Resolves #6713
This commit is contained in:
Eli W. Hunter
2020-03-14 10:43:10 -04:00
committed by Bjørn Erik Pedersen
parent 991934497e
commit 423b8f2fb8
6 changed files with 208 additions and 69 deletions

View File

@@ -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) {