generators

package
v1.0.0 Latest Latest
Warning

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

Go to latest
Published: Apr 4, 2024 License: MIT Imports: 9 Imported by: 0

Documentation

Index

Constants

This section is empty.

Variables

View Source
var ErrUnsupportedFileType = errors.New("unsupported file type")

ErrUnsupportedFileType is an error indicating that the file type is not supported.

Functions

This section is empty.

Types

type FormaterByExtMap

type FormaterByExtMap map[string]func(outputFile string) error

FormaterByExtMap is a map associating file extensions with formatting functions.

type Option

type Option func(*TemplateGenerator)

Option is a functional option to configure TemplateGenerator.

func WithExtraFormaterByExt

func WithExtraFormaterByExt(formaterByExt FormaterByExtMap) Option

WithExtraFormaterByExt adds extra file format functions to the TemplateGenerator.

func WithExtraFuncs

func WithExtraFuncs(funcs template.FuncMap) Option

WithExtraFuncs adds extra template functions to the TemplateGenerator.

type TemplateGenerator

type TemplateGenerator struct {
	// contains filtered or unexported fields
}

TemplateGenerator struct holds the configuration and methods for generating templates.

func NewTemplateGenerator

func NewTemplateGenerator(opts ...Option) *TemplateGenerator

NewTemplateGenerator creates a new TemplateGenerator instance with the provided options.

func (*TemplateGenerator) Build

func (tg *TemplateGenerator) Build(data any, templateName, templateContent string) (string, error)

Build executes the provided templateContent using the data supplied and returns the resulting string.

func (*TemplateGenerator) GenerateFile

func (tg *TemplateGenerator) GenerateFile(templatesMap map[string]string, fileName, fileTmpl, outputFile string, data any) error

GenerateFile generates a file using the provided template and data, and writes the output to the specified outputFile.

func (*TemplateGenerator) GenerateFiles

func (tg *TemplateGenerator) GenerateFiles(
	defaultTemplatesMap map[string]string, templatesMap map[string]string, data any, output string,
) error

GenerateFiles generates multiple files using the provided templates and data, and writes the outputs to the specified output directory.

Jump to

Keyboard shortcuts

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