generators

package
v0.11.0 Latest Latest
Warning

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

Go to latest
Published: Apr 14, 2024 License: MIT Imports: 5 Imported by: 0

Documentation

Index

Constants

This section is empty.

Variables

This section is empty.

Functions

func CreateFilesMap

func CreateFilesMap(files []config.File) map[string]File

CreateFilesMap creates a map of file configurations from a slice of config.File structs. Each element in the slice corresponds to a key-value pair in the map, where the key is the file name and the value is a File struct containing template and import information.

func CreateTemplatesMap added in v0.6.2

func CreateTemplatesMap(filenameTemplatesList []config.FilenameTemplateMap) map[string]string

CreateTemplatesMap creates a map of templates from a slice of config.FilenameTemplateMap structs. Each struct represents a map where keys are file names and values are corresponding templates. It merges these maps into a single map.

func FilterTemplatesMap added in v0.6.2

func FilterTemplatesMap(filter string, templatesMap map[string]string) map[string]string

FilterTemplatesMap filters a map of filenames to templates based on a given filter string. It iterates over each key-value pair in the input map and adds pairs to a new map if the filename contains the filter string.

func MustGenerateFile added in v0.11.0

func MustGenerateFile(tg *templategenerators.TemplateGenerator,
	templatesMap map[string]string, fileName, fileTmpl, outputFile string, data any,
)

MustGenerateFile generates a single file using the provided template. It logs any errors encountered during the generation process, except for the ErrUnsupportedFileType error, which is ignored.

func MustGenerateFiles added in v0.11.0

func MustGenerateFiles(tg *templategenerators.TemplateGenerator,
	defaultTemplatesMap map[string]string, filesMap map[string]File, data any, output string,
)

MustGenerateFiles generates multiple files at once using the provided templates. It logs any errors encountered during the generation process.

func NewGenerator added in v0.11.0

func NewGenerator() *templategenerators.TemplateGenerator

NewGenerator initialises a new instance of templategenerators.TemplateGenerator with additional template functions provided as a template.FuncMap.

Types

type File

type File struct {
	Tmpl    string
	Imports []string
}

Directories

Path Synopsis

Jump to

Keyboard shortcuts

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