Documentation ¶
Overview ¶
Package templates allows processing multiple templates which use common data
Index ¶
Constants ¶
This section is empty.
Variables ¶
var ( // ErrTemplateExecution is returned when template.Execute method fails ErrTemplateExecution = errors.New("executing template") // ErrSavingFiles is returned when an issue with processing templates occurs ErrSavingFiles = errors.New("saving processed terraform file") )
Functions ¶
This section is empty.
Types ¶
type FSTemplateProcessor ¶
type FSTemplateProcessor struct { TemplatesFS fs.FS TemplateTargets map[string]string AdditionalFuncs template.FuncMap }
FSTemplateProcessor allows working with templates stored as fs.FS it contains the fs.FS as source of templates as well as a map which stores template names with target files to which the result should be written All templates within TemplatesFS should have .tmpl extension AdditionalFuncs can be used to add custom template functions
func (FSTemplateProcessor) ProcessTemplates ¶
func (t FSTemplateProcessor) ProcessTemplates(data interface{}) error
ProcessTemplates parses templates located in fs.FS and executes them using the provided data result of each template execution is persisted in location provided in FSTemplateProcessor.TemplateTargets
type TemplateProcessor ¶
type TemplateProcessor interface { // ProcessTemplates is used to parse given template/templates using the given data as input // If template execution fails, ProcessTemplates should return ErrTemplateExecution ProcessTemplates(interface{}) error }
TemplateProcessor allows processing multiple templates which use common data