Documentation
¶
Index ¶
- func ReadAll(r io.Reader) (string, error)
- type AdvancedLoader
- type BaseLoader
- type CacheCleanup
- type CacheStats
- type CachingLoader
- type ChainLoader
- func (c *ChainLoader) AddLoader(loader AdvancedLoader)
- func (c *ChainLoader) GetSource(name string) (string, error)
- func (c *ChainLoader) GetSourceWithMetadata(name string) (*TemplateSource, error)
- func (c *ChainLoader) IsCached(name string) bool
- func (c *ChainLoader) ListTemplates() ([]string, error)
- func (c *ChainLoader) LoadTemplate(name string) (*parser.TemplateNode, error)
- func (c *ChainLoader) ResolveTemplateName(name string) string
- type DirectTemplateParser
- type DiscoveryLoader
- type EmbedLoader
- func (e *EmbedLoader) ClearCache()
- func (e *EmbedLoader) GetCacheStats() CacheStats
- func (e *EmbedLoader) GetSource(name string) (string, error)
- func (e *EmbedLoader) GetSourceWithMetadata(name string) (*TemplateSource, error)
- func (e *EmbedLoader) IsCached(name string) bool
- func (e *EmbedLoader) ListTemplates() ([]string, error)
- func (e *EmbedLoader) LoadTemplate(name string) (*parser.TemplateNode, error)
- func (e *EmbedLoader) ResolveTemplateName(name string) string
- func (e *EmbedLoader) SetExtensions(extensions []string)
- type FileSystemLoader
- func (f *FileSystemLoader) ClearCache()
- func (f *FileSystemLoader) GetCacheStats() CacheStats
- func (f *FileSystemLoader) GetSource(name string) (string, error)
- func (f *FileSystemLoader) GetSourceWithMetadata(name string) (*TemplateSource, error)
- func (f *FileSystemLoader) GetTemplateInfo(name string) (*TemplateInfo, error)
- func (f *FileSystemLoader) GetTemplatesByExtension(ext string) ([]string, error)
- func (f *FileSystemLoader) GetTemplatesInDirectory(dir string) ([]string, error)
- func (f *FileSystemLoader) IsCached(name string) bool
- func (f *FileSystemLoader) ListTemplates() ([]string, error)
- func (f *FileSystemLoader) LoadTemplate(name string) (*parser.TemplateNode, error)
- func (f *FileSystemLoader) ResolveTemplateName(name string) string
- func (f *FileSystemLoader) SearchTemplates(pattern string) ([]string, error)
- func (f *FileSystemLoader) SetExtensions(extensions []string)
- func (f *FileSystemLoader) SetFollowLinks(follow bool)
- type LRUCache
- func (c *LRUCache) Clear()
- func (c *LRUCache) Get(key string) (*parser.TemplateNode, *TemplateSource, bool)
- func (c *LRUCache) Keys() []string
- func (c *LRUCache) Put(key string, template *parser.TemplateNode, source *TemplateSource, ...)
- func (c *LRUCache) Remove(key string) bool
- func (c *LRUCache) Size() int
- func (c *LRUCache) Stats() CacheStats
- type LRUFileSystemLoader
- func (l *LRUFileSystemLoader) ClearCache()
- func (l *LRUFileSystemLoader) EvictExpiredItems() int
- func (l *LRUFileSystemLoader) GetCacheKeys() []string
- func (l *LRUFileSystemLoader) GetCacheStats() CacheStats
- func (l *LRUFileSystemLoader) IsCached(name string) bool
- func (l *LRUFileSystemLoader) LoadTemplate(name string) (*parser.TemplateNode, error)
- func (l *LRUFileSystemLoader) SetCacheTTL(ttl time.Duration)
- type Loader
- type LoaderFunc
- type StringLoader
- func (s *StringLoader) AddTemplate(name, content string)
- func (s *StringLoader) GetSource(name string) (string, error)
- func (s *StringLoader) GetSourceWithMetadata(name string) (*TemplateSource, error)
- func (s *StringLoader) IsCached(name string) bool
- func (s *StringLoader) ListTemplates() ([]string, error)
- func (s *StringLoader) LoadTemplate(name string) (*parser.TemplateNode, error)
- func (s *StringLoader) ResolveTemplateName(name string) string
- type TemplateInfo
- type TemplateParser
- type TemplateSource
Constants ¶
This section is empty.
Variables ¶
This section is empty.
Functions ¶
Types ¶
type AdvancedLoader ¶
type AdvancedLoader interface {
Loader
LoadTemplate(name string) (*parser.TemplateNode, error)
ResolveTemplateName(name string) string
GetSourceWithMetadata(name string) (*TemplateSource, error)
}
Enhanced Loader interface for advanced template loading
type BaseLoader ¶
type BaseLoader struct{}
Base implementation (keeping compatibility)
func (*BaseLoader) IsCached ¶
func (b *BaseLoader) IsCached(name string) bool
func (*BaseLoader) ListTemplates ¶
func (b *BaseLoader) ListTemplates() ([]string, error)
type CacheCleanup ¶
type CacheCleanup struct {
// contains filtered or unexported fields
}
LRU Cache cleanup helper
func NewCacheCleanup ¶
func NewCacheCleanup(cache *LRUCache, interval time.Duration) *CacheCleanup
NewCacheCleanup creates a new cache cleanup helper
type CacheStats ¶
CacheStats provides information about cache performance
type CachingLoader ¶
type CachingLoader interface {
AdvancedLoader
ClearCache()
GetCacheStats() CacheStats
}
CachingLoader interface for loaders that support caching
type ChainLoader ¶
type ChainLoader struct {
// contains filtered or unexported fields
}
ChainLoader combines multiple loaders, trying them in order
func NewChainLoader ¶
func NewChainLoader(loaders ...AdvancedLoader) *ChainLoader
NewChainLoader creates a new chain loader
func (*ChainLoader) AddLoader ¶
func (c *ChainLoader) AddLoader(loader AdvancedLoader)
AddLoader adds a loader to the chain
func (*ChainLoader) GetSource ¶
func (c *ChainLoader) GetSource(name string) (string, error)
GetSource implements the base Loader interface
func (*ChainLoader) GetSourceWithMetadata ¶
func (c *ChainLoader) GetSourceWithMetadata(name string) (*TemplateSource, error)
GetSourceWithMetadata gets template source with metadata using the first loader that succeeds
func (*ChainLoader) IsCached ¶
func (c *ChainLoader) IsCached(name string) bool
IsCached checks if any loader has the template cached
func (*ChainLoader) ListTemplates ¶
func (c *ChainLoader) ListTemplates() ([]string, error)
ListTemplates returns templates from all loaders
func (*ChainLoader) LoadTemplate ¶
func (c *ChainLoader) LoadTemplate(name string) (*parser.TemplateNode, error)
LoadTemplate loads a template using the first loader that succeeds
func (*ChainLoader) ResolveTemplateName ¶
func (c *ChainLoader) ResolveTemplateName(name string) string
ResolveTemplateName resolves using the first loader
type DirectTemplateParser ¶
type DirectTemplateParser struct {
// contains filtered or unexported fields
}
DirectTemplateParser parses templates without Environment coupling This eliminates circular dependencies in template loading
func NewDirectTemplateParser ¶
func NewDirectTemplateParser() *DirectTemplateParser
NewDirectTemplateParser creates a parser that works independently of Environment
func NewDirectTemplateParserWithConfig ¶
func NewDirectTemplateParserWithConfig(config *lexer.LexerConfig) *DirectTemplateParser
NewDirectTemplateParserWithConfig creates a parser with custom lexer configuration
func (*DirectTemplateParser) GetLexerConfig ¶
func (p *DirectTemplateParser) GetLexerConfig() *lexer.LexerConfig
GetLexerConfig returns the current lexer configuration
func (*DirectTemplateParser) ParseTemplate ¶
func (p *DirectTemplateParser) ParseTemplate(name, content string) (*parser.TemplateNode, error)
ParseTemplate parses template content directly without Environment involvement
func (*DirectTemplateParser) SetLexerConfig ¶
func (p *DirectTemplateParser) SetLexerConfig(config *lexer.LexerConfig)
SetLexerConfig updates the lexer configuration
type DiscoveryLoader ¶
type DiscoveryLoader interface {
AdvancedLoader
SearchTemplates(pattern string) ([]string, error)
GetTemplatesByExtension(ext string) ([]string, error)
GetTemplatesInDirectory(dir string) ([]string, error)
GetTemplateInfo(name string) (*TemplateInfo, error)
}
DiscoveryLoader interface for advanced template discovery
type EmbedLoader ¶
type EmbedLoader struct {
// contains filtered or unexported fields
}
EmbedLoader loads templates from embedded filesystem
func NewEmbedLoader ¶
func NewEmbedLoader(embedFS embed.FS, prefix string, parser TemplateParser) *EmbedLoader
NewEmbedLoader creates a new embed filesystem loader
func (*EmbedLoader) ClearCache ¶
func (e *EmbedLoader) ClearCache()
ClearCache clears the template cache
func (*EmbedLoader) GetCacheStats ¶
func (e *EmbedLoader) GetCacheStats() CacheStats
GetCacheStats returns cache performance statistics
func (*EmbedLoader) GetSource ¶
func (e *EmbedLoader) GetSource(name string) (string, error)
GetSource implements the base Loader interface
func (*EmbedLoader) GetSourceWithMetadata ¶
func (e *EmbedLoader) GetSourceWithMetadata(name string) (*TemplateSource, error)
GetSourceWithMetadata retrieves the source content of a template with metadata
func (*EmbedLoader) IsCached ¶
func (e *EmbedLoader) IsCached(name string) bool
IsCached checks if a template is cached
func (*EmbedLoader) ListTemplates ¶
func (e *EmbedLoader) ListTemplates() ([]string, error)
ListTemplates returns a list of all available templates
func (*EmbedLoader) LoadTemplate ¶
func (e *EmbedLoader) LoadTemplate(name string) (*parser.TemplateNode, error)
LoadTemplate loads and parses a template by name
func (*EmbedLoader) ResolveTemplateName ¶
func (e *EmbedLoader) ResolveTemplateName(name string) string
ResolveTemplateName resolves a template name to its canonical form
func (*EmbedLoader) SetExtensions ¶
func (e *EmbedLoader) SetExtensions(extensions []string)
SetExtensions sets the file extensions to search for
type FileSystemLoader ¶
type FileSystemLoader struct {
// contains filtered or unexported fields
}
FileSystemLoader loads templates from the filesystem
func NewFileSystemLoader ¶
func NewFileSystemLoader(searchPaths []string, parser TemplateParser) *FileSystemLoader
NewFileSystemLoader creates a new filesystem loader
func (*FileSystemLoader) ClearCache ¶
func (f *FileSystemLoader) ClearCache()
ClearCache clears the template cache
func (*FileSystemLoader) GetCacheStats ¶
func (f *FileSystemLoader) GetCacheStats() CacheStats
GetCacheStats returns cache performance statistics
func (*FileSystemLoader) GetSource ¶
func (f *FileSystemLoader) GetSource(name string) (string, error)
GetSource implements the base Loader interface
func (*FileSystemLoader) GetSourceWithMetadata ¶
func (f *FileSystemLoader) GetSourceWithMetadata(name string) (*TemplateSource, error)
GetSourceWithMetadata retrieves the source content of a template with metadata
func (*FileSystemLoader) GetTemplateInfo ¶
func (f *FileSystemLoader) GetTemplateInfo(name string) (*TemplateInfo, error)
GetTemplateInfo returns detailed information about a template
func (*FileSystemLoader) GetTemplatesByExtension ¶
func (f *FileSystemLoader) GetTemplatesByExtension(ext string) ([]string, error)
GetTemplatesByExtension returns all templates with a specific extension
func (*FileSystemLoader) GetTemplatesInDirectory ¶
func (f *FileSystemLoader) GetTemplatesInDirectory(dir string) ([]string, error)
GetTemplatesInDirectory returns all templates in a specific directory
func (*FileSystemLoader) IsCached ¶
func (f *FileSystemLoader) IsCached(name string) bool
IsCached checks if a template is cached
func (*FileSystemLoader) ListTemplates ¶
func (f *FileSystemLoader) ListTemplates() ([]string, error)
ListTemplates returns a list of all available templates
func (*FileSystemLoader) LoadTemplate ¶
func (f *FileSystemLoader) LoadTemplate(name string) (*parser.TemplateNode, error)
LoadTemplate loads and parses a template by name
func (*FileSystemLoader) ResolveTemplateName ¶
func (f *FileSystemLoader) ResolveTemplateName(name string) string
ResolveTemplateName resolves a template name to its canonical form
func (*FileSystemLoader) SearchTemplates ¶
func (f *FileSystemLoader) SearchTemplates(pattern string) ([]string, error)
SearchTemplates searches for templates matching a pattern (glob-style)
func (*FileSystemLoader) SetExtensions ¶
func (f *FileSystemLoader) SetExtensions(extensions []string)
SetExtensions sets the file extensions to search for
func (*FileSystemLoader) SetFollowLinks ¶
func (f *FileSystemLoader) SetFollowLinks(follow bool)
SetFollowLinks enables or disables following symbolic links
type LRUCache ¶
type LRUCache struct {
// contains filtered or unexported fields
}
LRUCache implements a Least Recently Used cache for templates
func NewLRUCache ¶
NewLRUCache creates a new LRU cache with the specified maximum size
func (*LRUCache) Get ¶
func (c *LRUCache) Get(key string) (*parser.TemplateNode, *TemplateSource, bool)
Get retrieves a template from the cache
func (*LRUCache) Put ¶
func (c *LRUCache) Put(key string, template *parser.TemplateNode, source *TemplateSource, ttl time.Duration)
Put adds or updates a template in the cache
type LRUFileSystemLoader ¶
type LRUFileSystemLoader struct {
*FileSystemLoader
// contains filtered or unexported fields
}
LRUFileSystemLoader extends FileSystemLoader with LRU caching
func NewLRUFileSystemLoader ¶
func NewLRUFileSystemLoader(searchPaths []string, parser TemplateParser, maxCacheSize int, cacheTTL time.Duration) *LRUFileSystemLoader
NewLRUFileSystemLoader creates a filesystem loader with LRU caching
func (*LRUFileSystemLoader) ClearCache ¶
func (l *LRUFileSystemLoader) ClearCache()
ClearCache clears the LRU cache
func (*LRUFileSystemLoader) EvictExpiredItems ¶
func (l *LRUFileSystemLoader) EvictExpiredItems() int
EvictExpiredItems manually removes expired items from the cache
func (*LRUFileSystemLoader) GetCacheKeys ¶
func (l *LRUFileSystemLoader) GetCacheKeys() []string
GetCacheKeys returns all keys currently in the LRU cache
func (*LRUFileSystemLoader) GetCacheStats ¶
func (l *LRUFileSystemLoader) GetCacheStats() CacheStats
GetCacheStats returns LRU cache statistics
func (*LRUFileSystemLoader) IsCached ¶
func (l *LRUFileSystemLoader) IsCached(name string) bool
IsCached checks if a template is cached in the LRU cache
func (*LRUFileSystemLoader) LoadTemplate ¶
func (l *LRUFileSystemLoader) LoadTemplate(name string) (*parser.TemplateNode, error)
LoadTemplate loads and parses a template with LRU caching
func (*LRUFileSystemLoader) SetCacheTTL ¶
func (l *LRUFileSystemLoader) SetCacheTTL(ttl time.Duration)
SetCacheTTL sets the time-to-live for cached templates
type Loader ¶
type Loader interface {
GetSource(name string) (string, error)
IsCached(name string) bool
ListTemplates() ([]string, error)
}
Base Loader interface (keeping compatibility with existing code)
type LoaderFunc ¶
func (LoaderFunc) IsCached ¶
func (f LoaderFunc) IsCached(name string) bool
func (LoaderFunc) ListTemplates ¶
func (f LoaderFunc) ListTemplates() ([]string, error)
type StringLoader ¶
type StringLoader struct {
// contains filtered or unexported fields
}
StringLoader loads templates from string content (useful for testing)
func NewStringLoader ¶
func NewStringLoader(parser TemplateParser) *StringLoader
NewStringLoader creates a new string loader
func (*StringLoader) AddTemplate ¶
func (s *StringLoader) AddTemplate(name, content string)
AddTemplate adds a template with the given name and content
func (*StringLoader) GetSource ¶
func (s *StringLoader) GetSource(name string) (string, error)
GetSource implements the base Loader interface
func (*StringLoader) GetSourceWithMetadata ¶
func (s *StringLoader) GetSourceWithMetadata(name string) (*TemplateSource, error)
GetSourceWithMetadata retrieves the source content of a template with metadata
func (*StringLoader) IsCached ¶
func (s *StringLoader) IsCached(name string) bool
IsCached always returns true for string loader (templates are in memory)
func (*StringLoader) ListTemplates ¶
func (s *StringLoader) ListTemplates() ([]string, error)
ListTemplates returns a list of all available templates
func (*StringLoader) LoadTemplate ¶
func (s *StringLoader) LoadTemplate(name string) (*parser.TemplateNode, error)
LoadTemplate loads and parses a template by name
func (*StringLoader) ResolveTemplateName ¶
func (s *StringLoader) ResolveTemplateName(name string) string
ResolveTemplateName resolves a template name (identity function for string loader)
type TemplateInfo ¶
type TemplateInfo struct {
Name string
Path string
Size int64
ModTime time.Time
Extension string
Directory string
Dependencies []string
}
TemplateInfo provides detailed information about a template
type TemplateParser ¶
type TemplateParser interface {
ParseTemplate(name, content string) (*parser.TemplateNode, error)
}
TemplateParser interface for parsing template content