Documentation ¶
Index ¶
- Variables
- func Append(s, append interface{}) (string, error)
- func Chomp(s interface{}) (string, error)
- func Combine(funcmaps ...map[string]interface{}) template.FuncMap
- func Contains(s, substr interface{}) (bool, error)
- func ContainsAny(s, chars interface{}) (bool, error)
- func DecodeBase64(s interface{}) (string, error)
- func EncodeBase64(s interface{}) (string, error)
- func EncodeJSON(v interface{}) (template.HTML, error)
- func FileExists(name interface{}) (bool, error)
- func Getenv(key interface{}) (string, error)
- func HTMLEscape(s interface{}) (string, error)
- func HTMLUnescape(s interface{}) (string, error)
- func HasPrefix(s interface{}, prefix string) (bool, error)
- func HasSuffix(s interface{}, suffix string) (bool, error)
- func Indent(s interface{}, n int) (string, error)
- func MD5(s interface{}) (string, error)
- func NIndent(s interface{}, n int) (string, error)
- func Now() time.Time
- func PadLeft(s, padding interface{}, n int) (string, error)
- func PadRight(s, padding interface{}, n int) (string, error)
- func Prepend(s, prepend interface{}) (string, error)
- func ReadDir(dirname interface{}) ([]os.FileInfo, error)
- func ReadFile(filename interface{}) ([]byte, error)
- func Replace(s, old, new interface{}) (string, error)
- func SHA1(s interface{}) (string, error)
- func SHA256(s interface{}) (string, error)
- func Split(s interface{}, sep string) ([]string, error)
- func SplitN(s interface{}, sep string, n int) ([]string, error)
- func Time(v interface{}, args ...interface{}) (interface{}, error)
- func TimeFormat(layout string, v interface{}) (string, error)
- func ToLower(s interface{}) (string, error)
- func ToTitle(s interface{}) (string, error)
- func ToUpper(s interface{}) (string, error)
- func ToYAML(s interface{}) (string, error)
- func Trim(s interface{}) (string, error)
- func TrimLeft(s interface{}, custet string) (string, error)
- func TrimPrefix(s interface{}, prefix string) (string, error)
- func TrimRight(s interface{}, custet string) (string, error)
- func TrimSuffix(s interface{}, suffix string) (string, error)
- func Urlize(s interface{}) (string, error)
Constants ¶
This section is empty.
Variables ¶
var Funcs = map[string]interface{}{ "append": Append, "base64Decode": DecodeBase64, "base64Encode": EncodeBase64, "chomp": Chomp, "contains": Contains, "containsAny": ContainsAny, "dateFormat": TimeFormat, "env": Getenv, "fileExists": FileExists, "htmlEscape": HTMLEscape, "htmlUnescape": HTMLUnescape, "hasPrefix": HasPrefix, "hasSuffix": HasSuffix, "indent": Indent, "jsonify": EncodeJSON, "lower": ToLower, "md5": MD5, "nindent": NIndent, "now": Now, "padLeft": PadLeft, "padRight": PadRight, "prepend": Prepend, "readDir": ReadDir, "readFile": ReadFile, "replace": Replace, "sha1": SHA1, "sha256": SHA256, "split": Split, "splitn": SplitN, "title": ToTitle, "time": Time, "trimLeft": TrimLeft, "trimRight": TrimRight, "trimPrefix": TrimPrefix, "trimSuffix": TrimSuffix, "trim": Trim, "upper": ToUpper, "urlize": Urlize, "toYaml": ToYAML, }
Funcs is a map of custom template functions.
var SafeFuncs = map[string]interface{}{ "append": Append, "base64Decode": DecodeBase64, "base64Encode": EncodeBase64, "chomp": Chomp, "contains": Contains, "containsAny": ContainsAny, "dateFormat": TimeFormat, "htmlEscape": HTMLEscape, "htmlUnescape": HTMLUnescape, "hasPrefix": HasPrefix, "hasSuffix": HasSuffix, "indent": Indent, "jsonify": EncodeJSON, "lower": ToLower, "md5": MD5, "nindent": NIndent, "now": Now, "padLeft": PadLeft, "padRight": PadRight, "prepend": Prepend, "replace": Replace, "sha1": SHA1, "sha256": SHA256, "split": Split, "splitn": SplitN, "title": ToTitle, "time": Time, "trimLeft": TrimLeft, "trimRight": TrimRight, "trimPrefix": TrimPrefix, "trimSuffix": TrimSuffix, "trim": Trim, "upper": ToUpper, "urlize": Urlize, "toYaml": ToYAML, }
SafeFuncs is a map of custom template functions. Functions that expose the environment and filesystem are excluded.
Functions ¶
func Append ¶
Append returns a slice of the string s, with append appended.
func Chomp ¶
Chomp returns a copy of s with all trailing newline characters removed.
func Combine ¶
Combine combines function maps.
func Contains ¶
Contains reports whether substr is within s.
func ContainsAny ¶
ContainsAny reports whether any Unicode code points in chars are within s.
func DecodeBase64 ¶
DecodeBase64 returns the base64 decoding of s.
func EncodeBase64 ¶
EncodeBase64 returns the base64 encoding of s.
func EncodeJSON ¶
EncodeJSON returns the JSON encoding of v.
func FileExists ¶
FileExists returns true if the file exists.
func Getenv ¶
Getenv retrieves the value of the environment variable named by the key.
func HTMLEscape ¶
HTMLEscape returns a copy of s with reserved HTML characters escaped.
func HTMLUnescape ¶
HTMLUnescape returns a copy of s with HTML escape sequences converted to plain text.
func HasPrefix ¶
HasPrefix tests whether the string s begins with prefix.
func HasSuffix ¶
HasSuffix tests whether the string s ends with suffix.
func Indent ¶
Indent returns a copy of the string s, with all lines prefixed with n spaces
func NIndent ¶
NIndent returns a copy of the string s, with all lines prefixed with n spaces, and a newline at the start. This is useful when interpolating into yaml, where you want each line indented by the exact same amount, but
func PadLeft ¶
PadLeft returns a slice of the string s, prefixed with n copies of padding.
func PadRight ¶
PadRight returns a slice of the string s, suffixed with n instances of the padding string.
func Prepend ¶
Prepend returns a slice of the string s, prepended with prepend.
func ReadDir ¶
ReadDir reads the directory named by dirname and returns a list of directory entries sorted by filename.
func ReadFile ¶
ReadFile reads the directory named by dirname and returns a list of directory entries sorted by filename.
func Replace ¶
Replace returns a copy of the string s with instances of old replaced by new.
func Split ¶
Split slices s into all substrings separated by sep and returns a slice of the substrings between those separators.
func SplitN ¶
SplitN slices s into substrings separated by sep and returns a slice of the substrings between those separators.
func Time ¶
func Time(v interface{}, args ...interface{}) (interface{}, error)
Time converts the textual representation of the datetime string into a time.Time interface.
func TimeFormat ¶
TimeFormat converts the textual representation of the datetime string into the other form or returns it of the time.Time value. These are formatted with the layout string
func ToLower ¶
ToLower returns a copy of the input s with all Unicode letters mapped to their lower case.
func ToTitle ¶
ToTitle returns a copy of the input s with all Unicode letters mapped to their title case.
func ToUpper ¶
ToUpper returns a copy of the input s with all Unicode letters mapped to their upper case.
func ToYAML ¶
toYAML takes an interface, marshals it to yaml, and returns a string. It will always return a string, even on marshal error (empty string).
This is designed to be called from a template.
func Trim ¶
Trim returns a slice of the string s, with all leading and trailing white space removed, as defined by Unicode.
func TrimLeft ¶
TrimLeft returns a slice of the string s with all leading Unicode code points contained in cutset removed.
func TrimPrefix ¶
TrimPrefix returns a slice of the string s, with all trailing Unicode code points contained in cutset removed.
func TrimRight ¶
TrimRight returns a slice of the string s, with all trailing Unicode code points contained in cutset removed.
func TrimSuffix ¶
TrimSuffix returns s without the provided trailing suffix string. If s doesn't end with suffix, s is returned unchanged.
Types ¶
This section is empty.