templates

package
v0.2.1 Latest Latest
Warning

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

Go to latest
Published: Mar 5, 2017 License: MIT Imports: 6 Imported by: 0

Documentation

Index

Constants

This section is empty.

Variables

This section is empty.

Functions

func DefaultFuncMap added in v0.2.0

func DefaultFuncMap(tmpl *Tpl) (err error)

DefaultFuncMap is an option function that sets the default values of the FuncMap

func DefaultVariables added in v0.2.0

func DefaultVariables(tmpl *Tpl) (err error)

DefaultVariables is an option function that sets the default values of Variables map

Types

type Option added in v0.2.0

type Option func(*Tpl) error

Option is an option function used by SetOptions to configure the struct

func AppendFiles added in v0.2.0

func AppendFiles(file string) Option

AppendFiles appends file parameter of the tmp struct. Files are the files parsed as templates

func AppendFuncMap added in v0.2.0

func AppendFuncMap(name string, value interface{}) Option

AppendFuncMap appends the funcMap parameter of the tmp struct. FuncMap functions are passed into the template

func AppendVariables added in v0.2.0

func AppendVariables(name, value string) Option

AppendVariables appends the variable parameter of the tmp struct. Variables are passed into the template

func Files added in v0.2.0

func Files(files []string) Option

Files sets parameter of the tmp struct. Files are the files parsed as templates

func FuncMap added in v0.2.0

func FuncMap(funcMap template.FuncMap) Option

FuncMap sets the funcMap parameter of the tmp struct. FuncMap functions are passed into the template

func Glob added in v0.2.0

func Glob(files string) Option

Glob sets parameter of the tmp struct. Files identified by the pattern are used as the templates

func MergeVariables added in v0.2.0

func MergeVariables(m map[string]string) Option

MergeVariables merges the variable parameter of the tmp struct with the passed in map. Variables are passed into the template

func Name added in v0.2.0

func Name(name string) Option

Name sets name parameter of the tmp struct. Name is the name of the template

func TemplateString added in v0.2.0

func TemplateString(templateString string) Option

TemplateString sets parameter of the tmp struct. TemplateString is the parsed as a string template

func Variables added in v0.2.0

func Variables(variable map[string]string) Option

Variables sets parameter of the tmp struct. Variables are passed into the template

type Tpl added in v0.2.0

type Tpl struct {
	Name           string
	TemplateString string
	Files          []string
	Glob           string
	Variables      map[string]string
	FuncMap        template.FuncMap
}

Tpl is the template struct the contains template options

func New added in v0.2.0

func New(options ...Option) (*Tpl, error)

New returns a new Tpl struct in`itialized with the option arguements pass in

func (*Tpl) Execute added in v0.2.0

func (tmpl *Tpl) Execute(wr io.Writer) (err error)

Execute parses and Execute the template as configured by the options. The output is written to the passed in writter

func (*Tpl) SetOptions added in v0.2.0

func (tmpl *Tpl) SetOptions(options ...Option) (*Tpl, error)

SetOptions runs the passed in option functions and returns an error is one occurs

Jump to

Keyboard shortcuts

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