Documentation ¶
Index ¶
- func ExtractArgs(ctx *Context, stp *ast.StructType, name string) ([]string, error)
- func ExtractTemplatesFromType(ctx *Context, stp *ast.StructType) (result []string, err error)
- func Output(ctx *Context, p string, data string) error
- func Process(arg string, searchPath []string) error
- func ProcessDir(dir string, searchPath []string) error
- func ProcessFilePath(p string, searchPath []string) error
- func RunTemplate(ctx *Context, templateName string, typeName string, st *ast.StructType) error
- type Context
- type TemplateContext
Constants ¶
This section is empty.
Variables ¶
This section is empty.
Functions ¶
func ExtractArgs ¶
ExtractArgs parses the arguments out of a template invocation, using the invoking fields tags.
func ExtractTemplatesFromType ¶
func ExtractTemplatesFromType( ctx *Context, stp *ast.StructType, ) (result []string, err error)
ExtractTemplatesFromType returns a slice of templates that have been invoked upon the provided struct.
func Process ¶
Process runs the code gen engine against `arg` using `searchPath` to lookup templates.
func ProcessDir ¶
ProcessDir runs the code gen engine against all files in `dir` using `searchPath` to lookup templates.
func ProcessFilePath ¶
ProcessFilePath runs the code gen engine against a single file, at `p` using `searchPath` to lookup templates.
func RunTemplate ¶
Types ¶
type Context ¶
type Context struct { Dir string SearchPaths []string Fset *token.FileSet Templates map[string]*template.Template PackageName string Imports map[string]bool Results map[string]string }
Context represents the context in which a code generation operation is run.
func NewContext ¶
NewContext initializes a new code generation context.
type TemplateContext ¶
type TemplateContext struct { Name string TemplateName string PackageName string Ctx *Context Struct *ast.StructType }
func (*TemplateContext) AddImport ¶
func (mc *TemplateContext) AddImport(name string) string
func (*TemplateContext) Args ¶
func (mc *TemplateContext) Args() []string
Click to show internal directories.
Click to hide internal directories.