Documentation
¶
Index ¶
- Variables
- type FormaterByExtMap
- type Option
- type TemplateGenerator
- func (tg *TemplateGenerator) Build(data any, templateName, templateContent string) (string, error)
- func (tg *TemplateGenerator) GenerateFile(templatesMap map[string]string, fileName, fileTmpl, outputFile string, ...) error
- func (tg *TemplateGenerator) GenerateFiles(defaultTemplatesMap map[string]string, templatesMap map[string]string, ...) error
Constants ¶
This section is empty.
Variables ¶
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 ¶
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 ¶
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.