templates

package
v0.11.9 Latest Latest
Warning

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

Go to latest
Published: Jun 30, 2020 License: MIT Imports: 16 Imported by: 0

Documentation

Index

Constants

This section is empty.

Variables

This section is empty.

Functions

func Call added in v0.11.5

func Call(p *types.Func) string

func Dump added in v0.11.5

func Dump(val interface{}) string

func Funcs added in v0.11.5

func Funcs() template.FuncMap

func LcFirst added in v0.11.5

func LcFirst(s string) string

func Render added in v0.11.5

func Render(cfg Options) error

Render renders a gql plugin template from the given Options. Render is an abstraction of the text/template package that makes it easier to write gqlgen plugins. If Options.Template is empty, the Render function will look for `.gotpl` files inside the directory where you wrote the plugin.

func ToGo added in v0.11.5

func ToGo(name string) string

func ToGoPrivate added in v0.11.5

func ToGoPrivate(name string) string

func TypeIdentifier added in v0.11.5

func TypeIdentifier(t types.Type) string

func UcFirst added in v0.11.5

func UcFirst(s string) string

Types

type Import added in v0.7.0

type Import struct {
	Name  string
	Path  string
	Alias string
}

func (*Import) String added in v0.7.0

func (i *Import) String() string

type Imports added in v0.7.0

type Imports struct {
	// contains filtered or unexported fields
}
var CurrentImports *Imports

CurrentImports keeps track of all the import declarations that are needed during the execution of a plugin. this is done with a global because subtemplates currently get called in functions. Lets aim to remove this eventually.

func (*Imports) Lookup added in v0.7.0

func (s *Imports) Lookup(path string) string

func (*Imports) LookupType added in v0.11.5

func (s *Imports) LookupType(t types.Type) string

func (*Imports) Reserve added in v0.7.0

func (s *Imports) Reserve(path string, aliases ...string) (string, error)

func (*Imports) String added in v0.7.0

func (s *Imports) String() string

type Options added in v0.11.5

type Options struct {
	// PackageName is a helper that specifies the package header declaration.
	// In other words, when you write the template you don't need to specify `package X`
	// at the top of the file. By providing PackageName in the Options, the Render
	// function will do that for you.
	PackageName string
	// Template is a string of the entire template that
	// will be parsed and rendered. If it's empty,
	// the plugin processor will look for .gotpl files
	// in the same directory of where you wrote the plugin.
	Template string
	// Filename is the name of the file that will be
	// written to the system disk once the template is rendered.
	Filename        string
	RegionTags      bool
	GeneratedHeader bool
	// PackageDoc is documentation written above the package line
	PackageDoc string
	// FileNotice is notice written below the package line
	FileNotice string
	// Data will be passed to the template execution.
	Data  interface{}
	Funcs template.FuncMap

	// Packages cache, you can find me on config.Config
	Packages *code.Packages
}

Options specify various parameters to rendering a template.

Jump to

Keyboard shortcuts

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