mirror of
https://github.com/gohugoio/hugo.git
synced 2025-08-29 22:29:56 +02:00
Add render hooks for inline and block passthrough snippets
Fixes #11927
This commit is contained in:
@@ -78,6 +78,19 @@ type CodeblockContext interface {
|
||||
Ordinal() int
|
||||
}
|
||||
|
||||
// PassThroughContext is the context passed to a passthrough render hook.
|
||||
type PassthroughContext interface {
|
||||
AttributesProvider
|
||||
text.Positioner
|
||||
PageProvider
|
||||
|
||||
// Currently one of "inline" or "block".
|
||||
Type() string
|
||||
|
||||
// Zero-based ordinal for all passthrough elements in the document.
|
||||
Ordinal() int
|
||||
}
|
||||
|
||||
type AttributesOptionsSliceProvider interface {
|
||||
AttributesSlice() []attributes.Attribute
|
||||
OptionsSlice() []attributes.Attribute
|
||||
@@ -91,6 +104,10 @@ type CodeBlockRenderer interface {
|
||||
RenderCodeblock(cctx context.Context, w hugio.FlexiWriter, ctx CodeblockContext) error
|
||||
}
|
||||
|
||||
type PassthroughRenderer interface {
|
||||
RenderPassthrough(cctx context.Context, w io.Writer, ctx PassthroughContext) error
|
||||
}
|
||||
|
||||
type IsDefaultCodeBlockRendererProvider interface {
|
||||
IsDefaultCodeBlockRenderer() bool
|
||||
}
|
||||
@@ -143,6 +160,7 @@ const (
|
||||
ImageRendererType
|
||||
HeadingRendererType
|
||||
CodeBlockRendererType
|
||||
PassthroughRendererType
|
||||
)
|
||||
|
||||
type GetRendererFunc func(t RendererType, id any) any
|
||||
|
Reference in New Issue
Block a user