code

package
v1.0.2 Latest Latest
Warning

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

Go to latest
Published: Dec 9, 2024 License: Apache-2.0 Imports: 15 Imported by: 0

Documentation

Index

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 (t *Template) AddedImports() []string

func (*Template) CompileBlock

func (t *Template) CompileBlock(ctx context.AdviceContext) (*dst.BlockStmt, error)

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

func (t *Template) CompileDeclarations(ctx context.AdviceContext) ([]dst.Decl, error)

CompileDeclarations generates new source based on this Template and extracts all produced declarations.

func (*Template) CompileExpression

func (t *Template) CompileExpression(ctx context.AdviceContext) (dst.Expr, error)

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.

func (*Template) Hash added in v1.0.0

func (t *Template) Hash(h *fingerprint.Hasher) error

func (*Template) UnmarshalYAML

func (t *Template) UnmarshalYAML(node *yaml.Node) (err error)

Directories

Path Synopsis

Jump to

Keyboard shortcuts

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