Documentation
¶
Overview ¶
Package template provides template function registry and management.
Package template provides validation with detailed error reporting.
Index ¶
Constants ¶
This section is empty.
Variables ¶
This section is empty.
Functions ¶
This section is empty.
Types ¶
type Engine ¶
type Engine struct {
// contains filtered or unexported fields
}
Engine manages template loading and execution.
func NewEngine ¶
func NewEngine(config *EngineConfig) *Engine
NewEngine creates a new template engine.
func (*Engine) CreateFuncMap ¶
CreateFuncMap creates a template.FuncMap with all registered functions.
func (*Engine) ListFunctions ¶
ListFunctions returns all registered function names.
type EngineConfig ¶
type EngineConfig struct {
BaseURL string
ContentMap map[string]*content.Node
Markdown goldmark.Markdown
StrictTemplates bool // Error on undefined variables
I18n *i18n.I18n
}
EngineConfig holds configuration for the template engine.
type Error ¶
type Error struct {
Template string // Template file name
Line int // Line number (1-indexed)
Column int // Column number (1-indexed)
Snippet string // Source code snippet
Message string // Error message
Hint string // Optional hint for fixing
}
Error represents a template error with source context.
type FuncRegistry ¶
type FuncRegistry struct {
// contains filtered or unexported fields
}
FuncRegistry manages template functions with metadata.
func CreateDefaultRegistry ¶
func CreateDefaultRegistry() *FuncRegistry
CreateDefaultRegistry creates a registry with all built-in functions.
func NewFuncRegistry ¶
func NewFuncRegistry() *FuncRegistry
NewFuncRegistry creates a new function registry.
func (*FuncRegistry) BuildFuncMap ¶
func (r *FuncRegistry) BuildFuncMap(ctx *funcs.SiteContext) template.FuncMap
BuildFuncMap creates a template.FuncMap with optional site context.
func (*FuncRegistry) Get ¶
func (r *FuncRegistry) Get(name string) (FuncDef, bool)
Get retrieves a function definition.
func (*FuncRegistry) List ¶
func (r *FuncRegistry) List() []string
List returns all registered function names.
func (*FuncRegistry) MustRegister ¶
func (r *FuncRegistry) MustRegister(name string, def FuncDef)
MustRegister registers a function or panics if it already exists.
type ValidationResult ¶
func (*ValidationResult) IsValid ¶
func (vr *ValidationResult) IsValid() bool
func (*ValidationResult) Report ¶
func (vr *ValidationResult) Report() string
type Validator ¶
type Validator struct {
// contains filtered or unexported fields
}
Validator validates templates before generation.
func NewValidator ¶
NewValidator creates a new template validator.