Documentation
¶
Overview ¶
Package template provides template utilities and functions for tinct plugins. This package is designed for use by both internal and external plugins.
Package template provides template utilities and functions for tinct plugins.
Index ¶
- func TemplateFuncs() template.FuncMap
- type Info
- type Loader
- func (l *Loader) CustomDir() string
- func (l *Loader) CustomPath(filename string) string
- func (l *Loader) DumpAllTemplates(force bool) ([]string, error)
- func (l *Loader) DumpTemplate(filename string, force bool) error
- func (l *Loader) GetInfo(filename string) Info
- func (l *Loader) HasCustomTemplate(filename string) bool
- func (l *Loader) ListEmbeddedTemplates() ([]string, error)
- func (l *Loader) Load(filename string) (content []byte, fromCustom bool, err error)
- func (l *Loader) WithCustomBase(customBase string) *Loader
- func (l *Loader) WithVerbose(verbose bool, logger Logger) *Loader
- type Logger
Constants ¶
This section is empty.
Variables ¶
This section is empty.
Functions ¶
func TemplateFuncs ¶
TemplateFuncs returns standard template functions for all output plugins. These functions provide consistent color access and formatting across all templates.
Types ¶
type Info ¶
type Info struct {
Filename string
EmbeddedExists bool
CustomExists bool
CustomPath string
UsingCustom bool
}
Info contains information about a template.
type Loader ¶
type Loader struct {
// contains filtered or unexported fields
}
Loader handles loading templates with support for custom overrides. It checks for custom templates in ~/.config/tinct/templates/{pluginName}/ and falls back to embedded templates if custom ones don't exist.
func New ¶
New creates a new template loader for the specified plugin. embedFS should be the embedded filesystem containing the plugin's default templates. pluginName is used to locate custom templates in ~/.config/tinct/templates/{pluginName}/.
func (*Loader) CustomDir ¶
CustomDir returns the directory where custom templates for this plugin would be located.
func (*Loader) CustomPath ¶
CustomPath returns the path where a custom template would be located.
func (*Loader) DumpAllTemplates ¶
DumpAllTemplates writes all embedded templates to the custom templates directory. Returns the list of successfully dumped templates and any errors encountered. If force is false and some templates already exist, it will skip those but continue processing remaining templates.
func (*Loader) DumpTemplate ¶
DumpTemplate writes an embedded template to the custom templates directory. If force is false, it will not overwrite existing custom templates.
func (*Loader) HasCustomTemplate ¶
HasCustomTemplate checks if a custom template exists for the given filename.
func (*Loader) ListEmbeddedTemplates ¶
ListEmbeddedTemplates returns a list of all embedded template files.
func (*Loader) Load ¶
Load reads a template file, checking for custom overrides first. filename should be the template filename (e.g., "theme.conf.tmpl"). Returns the template content and whether it was loaded from a custom override.
func (*Loader) WithCustomBase ¶
WithCustomBase sets a custom base directory for template storage. This is useful for dumping templates to a non-default location.