Documentation
¶
Overview ¶
Package exporttemplate provides templated renderer adapters for go-export.
Renderer is disabled by default; set Renderer.Enabled to true and supply Templates (TemplateExecutor). The default template name is "export".
Templates can use Go's html/template or Django/Pongo2-style syntax via a compatible executor wrapper (for example, wrapping pongo2 or github.com/gofiber/template/django/v3). BufferedStrategy is the default and enforces bounded buffering (DefaultMaxBufferedRows); StreamingStrategy streams rows through a channel so templates can range over .Rows without loading all rows into memory (channel-based rows work best with range blocks).
For server-side PDF output, pair the template renderer with adapters/pdf (wkhtmltopdf or a custom chromedp/rod engine).
Index ¶
Constants ¶
const DefaultMaxBufferedRows = 10000
DefaultMaxBufferedRows bounds template buffering by default.
Variables ¶
This section is empty.
Functions ¶
This section is empty.
Types ¶
type BufferedStrategy ¶
type BufferedStrategy struct {
MaxRows int
}
BufferedStrategy collects rows in memory before executing the template. MaxRows controls the maximum number of rows buffered before returning an error.
func (BufferedStrategy) Render ¶
func (s BufferedStrategy) Render(ctx context.Context, tmpl TemplateExecutor, name string, schema export.Schema, rows export.RowIterator, w io.Writer, opts export.RenderOptions) (export.RenderStats, error)
type Renderer ¶
type Renderer struct {
Enabled bool
Templates TemplateExecutor
TemplateName string
Strategy Strategy
}
Renderer renders templated HTML exports.
type Strategy ¶
type Strategy interface {
Render(ctx context.Context, tmpl TemplateExecutor, name string, schema export.Schema, rows export.RowIterator, w io.Writer, opts export.RenderOptions) (export.RenderStats, error)
}
Strategy renders template output with a selectable buffering strategy.
type StreamingStrategy ¶
type StreamingStrategy struct{}
StreamingStrategy streams rows into the template via a channel.
func (StreamingStrategy) Render ¶
func (s StreamingStrategy) Render(ctx context.Context, tmpl TemplateExecutor, name string, schema export.Schema, rows export.RowIterator, w io.Writer, opts export.RenderOptions) (export.RenderStats, error)
type TemplateData ¶
type TemplateExecutor ¶
TemplateExecutor executes a named template with data.
type TemplateMeta ¶
type TemplateMeta struct {
TemplateName string `json:"template_name,omitempty"`
Layout string `json:"layout,omitempty"`
Title string `json:"title,omitempty"`
Definition string `json:"definition,omitempty"`
Generated string `json:"generated,omitempty"`
GeneratedAt time.Time `json:"generated_at,omitempty"`
ChartConfig any `json:"chart_config,omitempty"`
Theme map[string]any `json:"theme,omitempty"`
Header map[string]any `json:"header,omitempty"`
Data map[string]any `json:"data,omitempty"`
}
TemplateData is the context passed to templates.