template

package
v0.0.6 Latest Latest
Warning

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

Go to latest
Published: Nov 28, 2024 License: Apache-2.0 Imports: 11 Imported by: 0

Documentation

Index

Constants

This section is empty.

Variables

This section is empty.

Functions

func CustomObjectStrictUnmarshalBlock added in v0.0.2

func CustomObjectStrictUnmarshalBlock(obj ast.Object) string

func CustomObjectUnmarshalBlock

func CustomObjectUnmarshalBlock(obj ast.Object) string

func ExtraBuilderDocsBlock

func ExtraBuilderDocsBlock(builder ast.Builder) string

func ExtraObjectDocsBlock

func ExtraObjectDocsBlock(obj ast.Object) string

func ExtraPackageDocsBlock

func ExtraPackageDocsBlock(schema *ast.Schema) string

Types

type Builder

type Builder struct {
	Package              string
	BuilderSignatureType string
	BuilderName          string
	ObjectName           string
	Imports              fmt.Stringer
	ImportAlias          string // alias to the pkg in which the object being built lives.
	Comments             []string
	Constructor          ast.Constructor
	Properties           []ast.StructField
	Options              []ast.Option
	Defaults             []OptionCall
}

type FuncMap

type FuncMap = gotemplate.FuncMap

type Option

type Option func(*Template) error

func Funcs

func Funcs(funcMap FuncMap) Option

func Parse

func Parse(payload string) Option

func ParseDirectories

func ParseDirectories(rootDirs ...string) Option

func ParseFS

func ParseFS(vfs fs.FS, rootDir string) Option

type OptionCall

type OptionCall struct {
	OptionName string
	Args       []string
}

type Template

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

func New

func New(name string, opts ...Option) (*Template, error)

func (*Template) ExecuteAsBytes

func (template *Template) ExecuteAsBytes(data any) ([]byte, error)

func (*Template) Exists

func (template *Template) Exists(name string) bool

func (*Template) Funcs

func (template *Template) Funcs(funcs FuncMap) *Template

func (*Template) Render

func (template *Template) Render(file string, data any) (string, error)

func (*Template) RenderAsBytes

func (template *Template) RenderAsBytes(file string, data any) ([]byte, error)

Jump to

Keyboard shortcuts

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