gotpl

package
v0.0.0-...-fe6f8ac Latest Latest
Warning

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

Go to latest
Published: Feb 7, 2022 License: MIT Imports: 14 Imported by: 0

Documentation

Overview

Package gotpl provides a Go template for xo.

Index

Constants

View Source
const (
	NotFirstKey   templates.ContextKey = "not-first"
	Int32Key      templates.ContextKey = "int32"
	Uint32Key     templates.ContextKey = "uint32"
	PkgKey        templates.ContextKey = "pkg"
	TagKey        templates.ContextKey = "tag"
	ImportKey     templates.ContextKey = "import"
	CustomKey     templates.ContextKey = "custom"
	ConflictKey   templates.ContextKey = "conflict"
	EscKey        templates.ContextKey = "esc"
	FieldTagKey   templates.ContextKey = "field-tag"
	ContextKey    templates.ContextKey = "context"
	InjectKey     templates.ContextKey = "inject"
	InjectFileKey templates.ContextKey = "inject-file"
)

Context keys.

Variables

View Source
var Files embed.FS

Files are the embedded Go templates.

Functions

func Conflict

func Conflict(ctx context.Context) string

Conflict returns conflict from the context.

func Context

func Context(ctx context.Context) string

Context returns context from the context.

func Custom

func Custom(ctx context.Context) string

Custom returns custom-pkg from the context.

func Esc

func Esc(ctx context.Context) []string

Esc returns esc from the context.

func FieldTag

func FieldTag(ctx context.Context) string

FieldTag returns field-tag from the context.

func Import

func Import(ctx context.Context) []string

Import returns import from the context.

func Inject

func Inject(ctx context.Context) string

Inject returns inject from the context.

func InjectFile

func InjectFile(ctx context.Context) string

InjectFile returns inject-file from the context.

func Int32

func Int32(ctx context.Context) string

Int32 returns int32 from the context.

func NotFirst

func NotFirst(ctx context.Context) bool

NotFirst returns not-first from the context.

func Pkg

func Pkg(ctx context.Context) string

Pkg returns pkg from the context.

func Tag

func Tag(ctx context.Context) []string

Tag returns tag from the context.

func Uint32

func Uint32(ctx context.Context) string

Uint32 returns uint32 from the context.

Types

type Funcs

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

Funcs is a set of template funcs.

func NewFuncs

func NewFuncs(ctx context.Context, knownTypes map[string]bool, shortNames map[string]string, first *bool) (*Funcs, error)

NewFuncs returns a set of template funcs.

func (*Funcs) AddKnownType

func (f *Funcs) AddKnownType(name string)

AddKnownType adds a known type.

func (*Funcs) FuncMap

func (f *Funcs) FuncMap() template.FuncMap

FuncMap returns the func map.

type PackageImport

type PackageImport struct {
	Alias string
	Pkg   string
}

PackageImport holds information about a Go package import.

func (PackageImport) String

func (v PackageImport) String() string

String satisfies the fmt.Stringer interface.

Jump to

Keyboard shortcuts

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