templates

package
v1.0.0 Latest Latest
Warning

This package is not in the latest version of its module.

Go to latest
Published: Dec 7, 2022 License: Apache-2.0 Imports: 12 Imported by: 0

Documentation

Overview

Package templates allows processing multiple templates which use common data

Index

Constants

This section is empty.

Variables

View Source
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

Jump to

Keyboard shortcuts

? : This menu
/ : Search site
f or F : Jump to
y or Y : Canonical URL