Documentation ¶
Overview ¶
Package templateutil provides various utility functions for golang templates
Index ¶
- func Aan(input string) string
- func Funcs(funcs template.FuncMap) template.FuncMap
- func InputDate(t sql.NullTime) (datestring string, err error)
- func InputTime(t sql.NullTime) (timestring string, err error)
- func Itoa(num interface{}) (string, error)
- func JoinSet(set map[string]bool, sep string) string
- func JoinSlice(slice []string, sep string) string
- func NullValue(x interface{}) string
- func Sha1Hash(inputs ...interface{}) (output string)
- func Sql(funcs template.FuncMap) template.FuncMap
- func Stringify(input interface{}) string
- func Txt(funcs template.FuncMap) template.FuncMap
Constants ¶
This section is empty.
Variables ¶
This section is empty.
Functions ¶
func Aan ¶
Aan is a Template Function that returns "an" or "a" depending on whether the first letter of the string is a vowel. It defaults to "a"
func Itoa ¶
Itoa is a Template Function that converts a number into a string. If a string is provided, the string is simply returned
func NullValue ¶
func NullValue(x interface{}) string
NullValue returns either the underlying value of the sql Null type, or "<NULL>" if the value is null. If the underlying value is an empty string, a pair of escaped double quotes \"\" will be returned to signify an empty string.
func Sha1Hash ¶
func Sha1Hash(inputs ...interface{}) (output string)
Sha1Hash is a Template Function that hashes a bunch of strings together using the SHA1 hash (the same that Git uses) and returns the first 8 characters from the hash
func Stringify ¶
func Stringify(input interface{}) string
Stringify is a Template Function that converts a generic object into a JSON string. If the object cannot be marshalled into a json string, it returns "null" instead. To ensure that your object can be converted into json, make sure it has json struct tags on its fields
Types ¶
This section is empty.