template

package
v1.1.0 Latest Latest
Warning

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

Go to latest
Published: Dec 14, 2023 License: Apache-2.0 Imports: 11 Imported by: 1

Documentation

Index

Constants

This section is empty.

Variables

This section is empty.

Functions

func GetPackageNameAndPath

func GetPackageNameAndPath(plugin *protogen.Plugin) (string, string, error)

GetPackageNameAndPath try to retrieve the golang module name from the list of .proto files.

Types

type Generated

type Generated struct {
	Filename     string
	TemplateName string
	Extension    string
	Data         *bytes.Buffer
}

Generated holds the template content already parsed, ready to be saved.

type Info

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

type Options

type Options struct {
	// StrictValidators if enabled forces us to use the validator function
	// for a template only if available. Otherwise, the template will be
	// ignored.
	StrictValidators bool
	Path             string
	Plugin           *protogen.Plugin
	Files            embed.FS        `validate:"required"`
	Context          TemplateContext `validate:"required"`
	HelperFunctions  map[string]interface{}
}

type TemplateContext

type TemplateContext interface {
	ValidateForExecute() map[string]TemplateValidator
	Extension() string
}

TemplateContext is an interface that a template file context, i.e., the object manipulated inside the template file, must implement.

type TemplateValidator

type TemplateValidator func() bool

type Templates

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

Templates is an object that holds information related to a group of template files, allowing them to be parsed later.

func LoadTemplates

func LoadTemplates(options *Options) (*Templates, error)

func (*Templates) Execute

func (t *Templates) Execute() ([]*Generated, error)

Jump to

Keyboard shortcuts

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