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 DecodeJSON(s interface{}) (map[string]interface{}, error)
- func DecodeYAML(s interface{}) (map[string]interface{}, error)
- func EncodeBase64(s interface{}) (string, error)
- func EncodeJSON(v interface{}) (template.HTML, error)
- func EncodeYAML(v interface{}) (template.HTML, error)
- func FileExists(name interface{}) (bool, error)
- func FindRE(expr string, content interface{}, limit ...interface{}) ([]string, error)
- func FirstUpper(s interface{}) (string, error)
- func Getenv(key interface{}) (string, error)
- func HTMLEscape(s interface{}) (string, error)
- func HTMLUnescape(s interface{}) (string, error)
- func HasPrefix(s, prefix interface{}) (bool, error)
- func HasSuffix(s, suffix interface{}) (bool, error)
- func MD5(s interface{}) (string, error)
- func Now() time.Time
- func PadLeft(s, padding, n interface{}) (string, error)
- func PadRight(s, padding, n interface{}) (string, error)
- func Prepend(s, prepend interface{}) (string, error)
- func ReadDir(dirname interface{}) ([]os.FileInfo, error)
- func ReadFile(filename interface{}) ([]byte, error)
- func Repeat(s, count interface{}) (string, error)
- func Replace(s, old, new interface{}) (string, error)
- func ReplaceRE(pattern, repl, s interface{}) (string, error)
- func SHA1(s interface{}) (string, error)
- func SHA256(s interface{}) (string, error)
- func SliceString(a interface{}, startEnd ...interface{}) (string, error)
- func Split(s interface{}, sep string) ([]string, error)
- func SplitN(s, sep, n interface{}) ([]string, error)
- func Stat(i interface{}) (os.FileInfo, 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 Trim(s interface{}) (string, error)
- func TrimLeft(s, cutset interface{}) (string, error)
- func TrimPrefix(s, prefix interface{}) (string, error)
- func TrimRight(s, cutset interface{}) (string, error)
- func TrimSuffix(s, suffix interface{}) (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, "getenv": Getenv, "findRE": FindRE, "fileExists": FileExists, "firstUpper": FirstUpper, "htmlEscape": HTMLEscape, "htmlUnescape": HTMLUnescape, "hasPrefix": HasPrefix, "hasSuffix": HasSuffix, "jsonify": EncodeJSON, "jsonEncode": EncodeJSON, "jsonDecode": DecodeJSON, "lower": ToLower, "md5": MD5, "now": Now, "padLeft": PadLeft, "padRight": PadRight, "prepend": Prepend, "readDir": ReadDir, "readFile": ReadFile, "replace": Replace, "replaceRE": ReplaceRE, "repeat": Repeat, "sha1": SHA1, "sha256": SHA256, "slicestr": SliceString, "split": Split, "splitn": SplitN, "stat": Stat, "title": ToTitle, "time": Time, "trimLeft": TrimLeft, "trimRight": TrimRight, "trimPrefix": TrimPrefix, "trimSuffix": TrimSuffix, "trim": Trim, "upper": ToUpper, "urlize": Urlize, "yamlEncode": EncodeYAML, "yamlDecode": DecodeYAML, }
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, "findRE": FindRE, "firstUpper": FirstUpper, "htmlEscape": HTMLEscape, "htmlUnescape": HTMLUnescape, "hasPrefix": HasPrefix, "hasSuffix": HasSuffix, "jsonify": EncodeJSON, "jsonEncode": EncodeJSON, "jsonDecode": DecodeJSON, "lower": ToLower, "md5": MD5, "now": Now, "padLeft": PadLeft, "padRight": PadRight, "prepend": Prepend, "repeat": Repeat, "replace": Replace, "replaceRE": ReplaceRE, "sha1": SHA1, "sha256": SHA256, "slicestr": SliceString, "split": Split, "splitn": SplitN, "title": ToTitle, "time": Time, "trimLeft": TrimLeft, "trimRight": TrimRight, "trimPrefix": TrimPrefix, "trimSuffix": TrimSuffix, "trim": Trim, "upper": ToUpper, "urlize": Urlize, "yamlEncode": EncodeYAML, "yamlDecode": DecodeYAML, }
SafeFuncs is a map of custom template functions. Functions that expose the environment and filesystem are excluded.
Functions ¶
func ContainsAny ¶
ContainsAny reports whether any Unicode code points in chars are within s.
func DecodeBase64 ¶
DecodeBase64 returns the base64 decoding of s.
func DecodeJSON ¶
DecodeJSON returns the JSON decoding of s.
func DecodeYAML ¶
DecodeYAML returns the YAML decoding of s.
func EncodeBase64 ¶
EncodeBase64 returns the base64 encoding of s.
func EncodeJSON ¶
EncodeJSON returns the JSON encoding of v.
func EncodeYAML ¶
EncodeYAML returns the YAML encoding of v.
func FileExists ¶
FileExists returns true if the file exists.
func FindRE ¶
FindRE returns a list of strings that match the regular expression. By default all matches will be included. The number of matches can be limited with an optional third parameter.
func FirstUpper ¶
FirstUpper returns a string with the first character as upper case.
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 PadRight ¶
PadRight returns a slice of the string s, suffixed with n instances of the padding string.
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 ReplaceRE ¶
ReplaceRE returns a copy of s, replacing all matches of the regular expression pattern with the replacement text repl.
func SliceString ¶
SliceString slices a string by specifying a half-open range with two indices, start and end. 1 and 4 creates a slice including elements 1 through 3. The end index can be omitted, it defaults to the string's length.
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 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.