Add render hooks for inline and block passthrough snippets

Fixes #11927
This commit is contained in:
Bjørn Erik Pedersen
2024-08-05 11:00:47 +02:00
parent 1781b18427
commit c6227f1d85
10 changed files with 328 additions and 34 deletions

View File

@@ -476,6 +476,11 @@ func (pco *pageContentOutput) initRenderHooks() error {
layoutDescriptor.Kind = "render-image"
case hooks.HeadingRendererType:
layoutDescriptor.Kind = "render-heading"
case hooks.PassthroughRendererType:
layoutDescriptor.Kind = "render-passthrough"
if id != nil {
layoutDescriptor.KindVariants = id.(string)
}
case hooks.CodeBlockRendererType:
layoutDescriptor.Kind = "render-codeblock"
if id != nil {

View File

@@ -915,6 +915,10 @@ func (hr hookRendererTemplate) RenderCodeblock(cctx context.Context, w hugio.Fle
return hr.templateHandler.ExecuteWithContext(cctx, hr.templ, w, ctx)
}
func (hr hookRendererTemplate) RenderPassthrough(cctx context.Context, w io.Writer, ctx hooks.PassthroughContext) error {
return hr.templateHandler.ExecuteWithContext(cctx, hr.templ, w, ctx)
}
func (hr hookRendererTemplate) ResolvePosition(ctx any) text.Position {
return hr.resolvePosition(ctx)
}