Documentation ¶
Index ¶
Constants ¶
This section is empty.
Variables ¶
This section is empty.
Functions ¶
func TempDir ¶
func TempDir() string
TempDir returns the volatile temporary directory that is returned by template function tempDir
func TempFile ¶
TempFile returns the volatile temporary file that is returned by template function tempFile
func TemplateFuncs ¶
TemplateFuncs declares a few standard functions to simplify working with templates
Available functions:
- {{ "some string" | contains "some" }} => true
- {{ "some string" | matches "^.+str.+$" }} => true
- {{ "some old string" | replace "old" "new" }} => "some new string"
- {{ "some old string" | replaceR "(old)" "$1 and new" }} => "some old and new string"
- {{ "some old string" | regex "(old)" "$1 and new" }} => "some old and new string" (alias to "replaceR")
- {{ "ABC" | lower }} => "abc"
- {{ "abc" | upper }} => "ABC"
- {{ " A " | trim }} => "A"
- {{ "--A-" | trimPrefix " " }} => "A-"
- {{ "--A-" | trimSuffix " " }} => "--A"
- {{ "A,B,C" | split "," }} => ["A", "B", "C"]
- {{ "A,B,C" | split "," | join ";" }} => "A;B;C"
- {{ "A ,B, C" | splitR "\\s*,\\s*" | join ";" }} => "A;B;C"
- {{ list "A" "B" "C" }} => ["A", "B", "C"]
- {{ with $v := map "k1" "v1" "k2" "v2" }} {{ .k1 }}-{{ .k2 }} {{ end }} => " v1-v2 "
- {{ with $v := list "A" "B" "C" "D" | map }} {{ ._0 }}-{{ ._1 }}-{{ ._3 }} {{ end }} => " A-B-D "
- {{ with $v := list "A" "B" "C" "D" | map "key" }} {{ .key | join "-" }} {{ end }} => " A-B-C-D "
- {{ tempDir }} => "/path/to/unique-tempdir"
- {{ tempFile "filename" }} => "/path/to/unique-tempdir/filename"
Types ¶
type DefaultData ¶
type DefaultData struct { Now time.Time CurrentDir string TempDir string BinaryDir string Hostname string OS string Arch string Env map[string]string }
DefaultData provides default variables for templates
func NewDefaultData ¶
func NewDefaultData(env map[string]string) (data DefaultData)
NewDefaultData returns an initialized DefaultData
func (*DefaultData) InitDefaults ¶
func (d *DefaultData) InitDefaults()
InitDefaults initializes DefaultData if not yet initialized
Click to show internal directories.
Click to hide internal directories.