Documentation
¶
Overview ¶
Package templatefuncs provides a set of template functions that are used in the internal template package.
Index ¶
- Constants
- Variables
- func NewFuncs(reporter Reporter) map[string]any
- type ANSIModule
- func (m *ANSIModule) BGBlack(s string) string
- func (m *ANSIModule) BGBlue(s string) string
- func (m *ANSIModule) BGBrightBlue(s string) string
- func (m *ANSIModule) BGBrightCyan(s string) string
- func (m *ANSIModule) BGBrightGreen(s string) string
- func (m *ANSIModule) BGBrightMagenta(s string) string
- func (m *ANSIModule) BGBrightRed(s string) string
- func (m *ANSIModule) BGBrightWhite(s string) string
- func (m *ANSIModule) BGBrightYellow(s string) string
- func (m *ANSIModule) BGCyan(s string) string
- func (m *ANSIModule) BGGray(s string) string
- func (m *ANSIModule) BGGreen(s string) string
- func (m *ANSIModule) BGMagenta(s string) string
- func (m *ANSIModule) BGRed(s string) string
- func (m *ANSIModule) BGWhite(s string) string
- func (m *ANSIModule) BGYellow(s string) string
- func (m *ANSIModule) Bold(s string) string
- func (m *ANSIModule) FGBlack(s string) string
- func (m *ANSIModule) FGBlue(s string) string
- func (m *ANSIModule) FGBrightBlue(s string) string
- func (m *ANSIModule) FGBrightCyan(s string) string
- func (m *ANSIModule) FGBrightGreen(s string) string
- func (m *ANSIModule) FGBrightMagenta(s string) string
- func (m *ANSIModule) FGBrightRed(s string) string
- func (m *ANSIModule) FGBrightWhite(s string) string
- func (m *ANSIModule) FGBrightYellow(s string) string
- func (m *ANSIModule) FGCyan(s string) string
- func (m *ANSIModule) FGGray(s string) string
- func (m *ANSIModule) FGGreen(s string) string
- func (m *ANSIModule) FGMagenta(s string) string
- func (m *ANSIModule) FGRed(s string) string
- func (m *ANSIModule) FGWhite(s string) string
- func (m *ANSIModule) FGYellow(s string) string
- func (m *ANSIModule) Faint(s string) string
- func (m *ANSIModule) Italic(s string) string
- func (m *ANSIModule) Reset(s string) string
- func (m *ANSIModule) Underline(s string) string
- type Base32Module
- type Base64Module
- func (m *Base64Module) Decode(s string) string
- func (m *Base64Module) Encode(s string) string
- func (m *Base64Module) RawDecode(s string) string
- func (m *Base64Module) RawEncode(s string) string
- func (m *Base64Module) RawURLDecode(s string) string
- func (m *Base64Module) RawURLEncode(s string) string
- func (m *Base64Module) URLDecode(s string) string
- func (m *Base64Module) URLEncode(s string) string
- type BuildModule
- type CRC32Module
- type CRC64Module
- type FNVModule
- type GZipModule
- type HTMLModule
- type JSONModule
- type LineModule
- func (m *LineModule) CutPrefix(prefix, s string) string
- func (m *LineModule) CutSuffix(suffix, s string) string
- func (m *LineModule) Dedent(lines string) string
- func (m *LineModule) Indent(indent int, text string) string
- func (m *LineModule) Prefix(prefix, text string) string
- func (m *LineModule) Resize(columns int, text string) string
- func (m *LineModule) Split(lines string) []string
- func (m *LineModule) Suffix(suffix, text string) string
- func (m *LineModule) TabIndent(indent int, text string) string
- func (m *LineModule) Trim(cutset, s string) string
- func (m *LineModule) TrimLeft(cutset, s string) string
- func (m *LineModule) TrimRight(cutset, s string) string
- func (m *LineModule) TrimSpace(s string) string
- type ListModule
- type Reporter
- type ReporterFunc
- type SHAModule
- func (m *SHAModule) Sum1(s string) string
- func (m *SHAModule) Sum224(s string) string
- func (m *SHAModule) Sum256(s string) string
- func (m *SHAModule) Sum384(s string) string
- func (m *SHAModule) Sum512(s string) string
- func (m *SHAModule) Sum512_224(s string) string
- func (m *SHAModule) Sum512_256(s string) string
- type StringModule
- func (m *StringModule) Acronym(s string) string
- func (m *StringModule) Camel(s string) string
- func (m *StringModule) CamelInitialism(s string) string
- func (m *StringModule) Char(n int, s string) string
- func (m *StringModule) CutPrefix(prefix, s string) string
- func (m *StringModule) CutSuffix(suffix, s string) string
- func (m *StringModule) Fields(s string) []string
- func (m *StringModule) First(s string) string
- func (m *StringModule) Join(sep string, a []string) string
- func (m *StringModule) Kebab(s string) string
- func (m *StringModule) Last(s string) string
- func (m *StringModule) Lower(s string) string
- func (m *StringModule) Pascal(s string) string
- func (m *StringModule) PascalInitialism(s string) string
- func (m *StringModule) Prefix(prefix, content string) string
- func (m *StringModule) Quote(content string) string
- func (m *StringModule) Repeat(n int, text string) string
- func (m *StringModule) Replace(old, new, text string) string
- func (m *StringModule) Reverse(s string) string
- func (m *StringModule) Shout(s string) string
- func (m *StringModule) Snake(s string) string
- func (m *StringModule) Split(sep, text string) []string
- func (m *StringModule) Strip(content string) string
- func (m *StringModule) Substring(start, length int, s string) string
- func (m *StringModule) Suffix(suffix, content string) string
- func (m *StringModule) Title(s string) string
- func (m *StringModule) Trim(cutset, s string) string
- func (m *StringModule) TrimLeft(cutset, s string) string
- func (m *StringModule) TrimRight(cutset, s string) string
- func (m *StringModule) TrimSpace(s string) string
- func (m *StringModule) Unquote(content string) (string, error)
- func (m *StringModule) Upper(s string) string
- type YAMLModule
Constants ¶
View Source
const ( // StringOnError is the default string returned when an error occurs in a // template function. StringOnError = "{{ an error occurred }}" )
Variables ¶
View Source
var ( ErrInvalidType = fmt.Errorf("invalid type") ErrIndexOutOfRange = fmt.Errorf("index out of range") )
Functions ¶
Types ¶
type ANSIModule ¶
type ANSIModule struct{}
func (*ANSIModule) BGBlack ¶
func (m *ANSIModule) BGBlack(s string) string
func (*ANSIModule) BGBlue ¶
func (m *ANSIModule) BGBlue(s string) string
func (*ANSIModule) BGBrightBlue ¶
func (m *ANSIModule) BGBrightBlue(s string) string
func (*ANSIModule) BGBrightCyan ¶
func (m *ANSIModule) BGBrightCyan(s string) string
func (*ANSIModule) BGBrightGreen ¶
func (m *ANSIModule) BGBrightGreen(s string) string
func (*ANSIModule) BGBrightMagenta ¶
func (m *ANSIModule) BGBrightMagenta(s string) string
func (*ANSIModule) BGBrightRed ¶
func (m *ANSIModule) BGBrightRed(s string) string
func (*ANSIModule) BGBrightWhite ¶
func (m *ANSIModule) BGBrightWhite(s string) string
func (*ANSIModule) BGBrightYellow ¶
func (m *ANSIModule) BGBrightYellow(s string) string
func (*ANSIModule) BGCyan ¶
func (m *ANSIModule) BGCyan(s string) string
func (*ANSIModule) BGGray ¶
func (m *ANSIModule) BGGray(s string) string
func (*ANSIModule) BGGreen ¶
func (m *ANSIModule) BGGreen(s string) string
func (*ANSIModule) BGMagenta ¶
func (m *ANSIModule) BGMagenta(s string) string
func (*ANSIModule) BGRed ¶
func (m *ANSIModule) BGRed(s string) string
func (*ANSIModule) BGWhite ¶
func (m *ANSIModule) BGWhite(s string) string
func (*ANSIModule) BGYellow ¶
func (m *ANSIModule) BGYellow(s string) string
func (*ANSIModule) Bold ¶
func (m *ANSIModule) Bold(s string) string
func (*ANSIModule) FGBlack ¶
func (m *ANSIModule) FGBlack(s string) string
func (*ANSIModule) FGBlue ¶
func (m *ANSIModule) FGBlue(s string) string
func (*ANSIModule) FGBrightBlue ¶
func (m *ANSIModule) FGBrightBlue(s string) string
func (*ANSIModule) FGBrightCyan ¶
func (m *ANSIModule) FGBrightCyan(s string) string
func (*ANSIModule) FGBrightGreen ¶
func (m *ANSIModule) FGBrightGreen(s string) string
func (*ANSIModule) FGBrightMagenta ¶
func (m *ANSIModule) FGBrightMagenta(s string) string
func (*ANSIModule) FGBrightRed ¶
func (m *ANSIModule) FGBrightRed(s string) string
func (*ANSIModule) FGBrightWhite ¶
func (m *ANSIModule) FGBrightWhite(s string) string
func (*ANSIModule) FGBrightYellow ¶
func (m *ANSIModule) FGBrightYellow(s string) string
func (*ANSIModule) FGCyan ¶
func (m *ANSIModule) FGCyan(s string) string
func (*ANSIModule) FGGray ¶
func (m *ANSIModule) FGGray(s string) string
func (*ANSIModule) FGGreen ¶
func (m *ANSIModule) FGGreen(s string) string
func (*ANSIModule) FGMagenta ¶
func (m *ANSIModule) FGMagenta(s string) string
func (*ANSIModule) FGRed ¶
func (m *ANSIModule) FGRed(s string) string
func (*ANSIModule) FGWhite ¶
func (m *ANSIModule) FGWhite(s string) string
func (*ANSIModule) FGYellow ¶
func (m *ANSIModule) FGYellow(s string) string
func (*ANSIModule) Faint ¶
func (m *ANSIModule) Faint(s string) string
func (*ANSIModule) Italic ¶
func (m *ANSIModule) Italic(s string) string
func (*ANSIModule) Reset ¶
func (m *ANSIModule) Reset(s string) string
func (*ANSIModule) Underline ¶
func (m *ANSIModule) Underline(s string) string
type Base32Module ¶
type Base32Module struct {
Reporter Reporter
}
func (*Base32Module) Decode ¶
func (m *Base32Module) Decode(s string) string
func (*Base32Module) Encode ¶
func (m *Base32Module) Encode(s string) string
func (*Base32Module) HexDecode ¶
func (m *Base32Module) HexDecode(s string) string
func (*Base32Module) HexEncode ¶
func (m *Base32Module) HexEncode(s string) string
type Base64Module ¶
type Base64Module struct {
Reporter Reporter
}
func (*Base64Module) Decode ¶
func (m *Base64Module) Decode(s string) string
func (*Base64Module) Encode ¶
func (m *Base64Module) Encode(s string) string
func (*Base64Module) RawDecode ¶
func (m *Base64Module) RawDecode(s string) string
func (*Base64Module) RawEncode ¶
func (m *Base64Module) RawEncode(s string) string
func (*Base64Module) RawURLDecode ¶
func (m *Base64Module) RawURLDecode(s string) string
func (*Base64Module) RawURLEncode ¶
func (m *Base64Module) RawURLEncode(s string) string
func (*Base64Module) URLDecode ¶
func (m *Base64Module) URLDecode(s string) string
func (*Base64Module) URLEncode ¶
func (m *Base64Module) URLEncode(s string) string
type BuildModule ¶
type BuildModule struct{}
func (*BuildModule) Context ¶
func (m *BuildModule) Context() *build.Context
func (*BuildModule) VCS ¶
func (m *BuildModule) VCS() string
func (*BuildModule) VCSRevision ¶
func (m *BuildModule) VCSRevision() string
func (*BuildModule) VCSTime ¶
func (m *BuildModule) VCSTime() string
type CRC32Module ¶
type CRC32Module struct{}
func (*CRC32Module) Castagnoli ¶
func (m *CRC32Module) Castagnoli(s string) uint32
func (*CRC32Module) IEEE ¶
func (m *CRC32Module) IEEE(s string) uint32
func (*CRC32Module) Koopman ¶
func (m *CRC32Module) Koopman(s string) uint32
type CRC64Module ¶
type CRC64Module struct{}
func (*CRC64Module) ECMA ¶
func (m *CRC64Module) ECMA(s string) uint64
func (*CRC64Module) ISO ¶
func (m *CRC64Module) ISO(s string) uint64
type GZipModule ¶
type GZipModule struct {
Reporter Reporter
}
func (*GZipModule) Decode ¶
func (m *GZipModule) Decode(s string) string
func (*GZipModule) Encode ¶
func (m *GZipModule) Encode(s string) string
type HTMLModule ¶
type HTMLModule struct{}
func (*HTMLModule) Escape ¶
func (m *HTMLModule) Escape(s string) string
func (*HTMLModule) Unescape ¶
func (m *HTMLModule) Unescape(s string) string
type JSONModule ¶
type JSONModule struct {
Reporter Reporter
}
func (*JSONModule) Encode ¶
func (m *JSONModule) Encode(data any) string
func (*JSONModule) EncodeIndent ¶
func (m *JSONModule) EncodeIndent(data any) string
type LineModule ¶
type LineModule struct{}
func (*LineModule) CutPrefix ¶
func (m *LineModule) CutPrefix(prefix, s string) string
func (*LineModule) CutSuffix ¶
func (m *LineModule) CutSuffix(suffix, s string) string
func (*LineModule) Dedent ¶
func (m *LineModule) Dedent(lines string) string
func (*LineModule) Prefix ¶
func (m *LineModule) Prefix(prefix, text string) string
func (*LineModule) Split ¶
func (m *LineModule) Split(lines string) []string
func (*LineModule) Suffix ¶
func (m *LineModule) Suffix(suffix, text string) string
func (*LineModule) Trim ¶
func (m *LineModule) Trim(cutset, s string) string
func (*LineModule) TrimLeft ¶
func (m *LineModule) TrimLeft(cutset, s string) string
func (*LineModule) TrimRight ¶
func (m *LineModule) TrimRight(cutset, s string) string
func (*LineModule) TrimSpace ¶
func (m *LineModule) TrimSpace(s string) string
type ListModule ¶
type ListModule struct {
Reporter Reporter
}
func (*ListModule) First ¶
func (m *ListModule) First(v any) any
func (*ListModule) Last ¶
func (m *ListModule) Last(v any) any
func (*ListModule) Length ¶
func (m *ListModule) Length(v any) int
func (*ListModule) Reverse ¶
func (m *ListModule) Reverse(v any) any
type ReporterFunc ¶
type ReporterFunc func(error)
func (ReporterFunc) Report ¶
func (f ReporterFunc) Report(err error)
type SHAModule ¶
type SHAModule struct{}
func (*SHAModule) Sum512_224 ¶
func (*SHAModule) Sum512_256 ¶
type StringModule ¶
type StringModule struct {
Reporter Reporter
}
func (*StringModule) Acronym ¶
func (m *StringModule) Acronym(s string) string
func (*StringModule) Camel ¶
func (m *StringModule) Camel(s string) string
func (*StringModule) CamelInitialism ¶
func (m *StringModule) CamelInitialism(s string) string
func (*StringModule) CutPrefix ¶
func (m *StringModule) CutPrefix(prefix, s string) string
func (*StringModule) CutSuffix ¶
func (m *StringModule) CutSuffix(suffix, s string) string
func (*StringModule) Fields ¶
func (m *StringModule) Fields(s string) []string
func (*StringModule) First ¶
func (m *StringModule) First(s string) string
func (*StringModule) Kebab ¶
func (m *StringModule) Kebab(s string) string
func (*StringModule) Last ¶
func (m *StringModule) Last(s string) string
func (*StringModule) Lower ¶
func (m *StringModule) Lower(s string) string
func (*StringModule) Pascal ¶
func (m *StringModule) Pascal(s string) string
func (*StringModule) PascalInitialism ¶
func (m *StringModule) PascalInitialism(s string) string
func (*StringModule) Prefix ¶
func (m *StringModule) Prefix(prefix, content string) string
func (*StringModule) Quote ¶
func (m *StringModule) Quote(content string) string
func (*StringModule) Replace ¶
func (m *StringModule) Replace(old, new, text string) string
func (*StringModule) Reverse ¶
func (m *StringModule) Reverse(s string) string
func (*StringModule) Shout ¶
func (m *StringModule) Shout(s string) string
func (*StringModule) Snake ¶
func (m *StringModule) Snake(s string) string
func (*StringModule) Split ¶
func (m *StringModule) Split(sep, text string) []string
func (*StringModule) Strip ¶
func (m *StringModule) Strip(content string) string
func (*StringModule) Substring ¶
func (m *StringModule) Substring(start, length int, s string) string
func (*StringModule) Suffix ¶
func (m *StringModule) Suffix(suffix, content string) string
func (*StringModule) Title ¶
func (m *StringModule) Title(s string) string
func (*StringModule) Trim ¶
func (m *StringModule) Trim(cutset, s string) string
func (*StringModule) TrimLeft ¶
func (m *StringModule) TrimLeft(cutset, s string) string
func (*StringModule) TrimRight ¶
func (m *StringModule) TrimRight(cutset, s string) string
func (*StringModule) TrimSpace ¶
func (m *StringModule) TrimSpace(s string) string
func (*StringModule) Upper ¶
func (m *StringModule) Upper(s string) string
type YAMLModule ¶
type YAMLModule struct {
Reporter Reporter
}
func (*YAMLModule) Encode ¶
func (m *YAMLModule) Encode(data any) string
Click to show internal directories.
Click to hide internal directories.