template

package
v0.5.0 Latest Latest
Warning

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

Go to latest
Published: Dec 13, 2023 License: Apache-2.0 Imports: 21 Imported by: 0

Documentation

Index

Constants

View Source
const KIND_TEMPLATER = "templater"

Variables

This section is empty.

Functions

func ReadSimpleSettings

func ReadSimpleSettings(fs vfs.FileSystem, path string) (map[string]string, error)

func Register

func Register(name string, fac TemplaterFactory, desc string)

func SplitYamlDocuments

func SplitYamlDocuments(data []byte) ([][]byte, error)

func Usage

func Usage(scheme Registry) string

Types

type GoTemplater

type GoTemplater struct{}

func (GoTemplater) Process

func (g GoTemplater) Process(data string, values Values) (string, error)

type MergeTemplater

type MergeTemplater struct{}

func (MergeTemplater) Process

func (g MergeTemplater) Process(data string, values Values) (string, error)

type None

type None struct{}

func (*None) Process

func (s *None) Process(data string, values Values) (string, error)

Template templates a string with the parsed vars.

type Options

type Options struct {
	Default   string
	Mode      string
	UseEnv    bool
	Templater Templater
	Vars      Values
}

Options defines the options for cli templating.

func (*Options) AddFlags

func (o *Options) AddFlags(fs *pflag.FlagSet)

func (*Options) Complete

func (o *Options) Complete(fs vfs.FileSystem) error

func (*Options) DefaultMode

func (o *Options) DefaultMode() string

func (*Options) Execute

func (o *Options) Execute(data string) (string, error)

Execute templates a string with the parsed vars.

func (*Options) FilterSettings

func (o *Options) FilterSettings(args ...string) []string

FilterSettings parses commandline argument variables. it returns all non variable arguments.

func (*Options) ParseSettings

func (o *Options) ParseSettings(fs vfs.FileSystem, paths ...string) error

func (*Options) Usage

func (o *Options) Usage() string

Usage prints out the usage for templating.

type Registry

type Registry interface {
	Register(name string, fac TemplaterFactory, desc string)
	Create(name string, fs vfs.FileSystem) (Templater, error)
	Describe(name string) (string, error)
	KnownTypeNames() []string
}

func DefaultRegistry

func DefaultRegistry() Registry

func NewRegistry

func NewRegistry() Registry

type Spiff

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

func (*Spiff) Process

func (s *Spiff) Process(data string, values Values) (string, error)

type Subst

type Subst struct{}

func (*Subst) Process

func (s *Subst) Process(data string, values Values) (string, error)

Template templates a string with the parsed vars.

type Templater

type Templater interface {
	Process(data string, values Values) (string, error)
}

func NewGo

func NewGo() Templater

func NewMerge

func NewMerge() Templater

func NewNone

func NewNone() Templater

func NewSpiff

func NewSpiff(fs vfs.FileSystem) Templater

func NewSubst

func NewSubst() Templater

type TemplaterFactory

type TemplaterFactory func(system vfs.FileSystem) Templater

type Values

type Values map[string]interface{}

func ReadYAMLSettings

func ReadYAMLSettings(fs vfs.FileSystem, path string) (Values, error)

Jump to

Keyboard shortcuts

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