Documentation ¶
Index ¶
- type DirectiveArgument
- type Template
- func (t *Template) AddedImports() []string
- func (t *Template) CompileBlock(ctx context.AdviceContext) (*dst.BlockStmt, error)
- func (t *Template) CompileDeclarations(ctx context.AdviceContext) ([]dst.Decl, error)
- func (t *Template) CompileExpression(ctx context.AdviceContext) (dst.Expr, error)
- func (t *Template) Hash(h *fingerprint.Hasher) error
- func (t *Template) UnmarshalYAML(node *yaml.Node) (err error)
Constants ¶
This section is empty.
Variables ¶
This section is empty.
Functions ¶
This section is empty.
Types ¶
type DirectiveArgument ¶
type DirectiveArgument struct { Key string // They key of the argument Value string // The value of the argument }
DirectiveArgument represents arguments provided to directives (`//<directive> <args...>`), where arguments are parsed as space-separated key:value pairs.
type Template ¶
type Template struct { Imports map[string]string Source string Lang context.GoLangVersion // contains filtered or unexported fields }
func MustTemplate ¶
func MustTemplate(text string, imports map[string]string, lang context.GoLangVersion) (template *Template)
MustTemplate is the same as NewTemplate, but panics if an error occurs.
func NewTemplate ¶
func NewTemplate(text string, imports map[string]string, lang context.GoLangVersion) (*Template, error)
NewTemplate creates a new Template using the provided template string and imports map. The imports map associates names to import paths. The produced AST nodes will feature qualified *dst.Ident nodes in all places where a property of mapped names is selected.
func (*Template) AddedImports ¶
func (*Template) CompileBlock ¶
CompileBlock generates new source based on this Template and wraps the resulting dst.Stmt nodes in a new *dst.BlockStmt. The provided context.Context and *dstutil.Cursor are used to supply context information to the template functions.
func (*Template) CompileDeclarations ¶
CompileDeclarations generates new source based on this Template and extracts all produced declarations.
func (*Template) CompileExpression ¶
CompileExpression generates new source based on this Template and extracts the produced dst.Expr node. The provided context.Context and *dstutil.Cursor are used to supply context information to the template functions. The provided dst.Expr will be copied in places where the `{{Expr}}` template function is used, unless `expr` is nil.