Documentation
¶
Index ¶
- Constants
- func CompileRegexp(pattern string) *regexp.Regexp
- func CompileTemplate(temp string) (*template.Template, error)
- func EvalTemplate(temp *template.Template, params Parameters) (string, error)
- func FormatDuration(duration time.Duration) string
- func GetFullEventKey(event slack.MessageEvent) string
- func GetMessageTime(event slack.MessageEvent) time.Time
- func GetShortEventKey(event slack.MessageEvent) string
- func ParseDuration(input string) (time.Duration, error)
- func RegexpResultToParams(regexp *regexp.Regexp, match []string) map[string]string
- func RegisterFunctions(funcMap template.FuncMap)
- type Parameters
- type TemplateFunctionProvider
Examples ¶
Constants ¶
const FullMatch = "match"
FullMatch is the key of the "Result" which contains the initial full string of the matching process
Variables ¶
This section is empty.
Functions ¶
func CompileRegexp ¶
CompileRegexp compiles a regexp to a unified regexp layout: - case insensitive - always match a full line -> implicitly adds "^" and "$"
func CompileTemplate ¶
CompileTemplate pre compiles a template and returns an error if an function is not available etc
func EvalTemplate ¶
func EvalTemplate(temp *template.Template, params Parameters) (string, error)
EvalTemplate renders the template
func FormatDuration ¶
FormatDuration shortens a duration string representation. e.g. "12m1.231001s" -> "12m1s"
func GetFullEventKey ¶
func GetFullEventKey(event slack.MessageEvent) string
GetFullEventKey builds a key over user-channel-threadtimestamp
func GetMessageTime ¶
func GetMessageTime(event slack.MessageEvent) time.Time
GetMessageTime will return a time.Time of the sent date from the MessageEvent
func GetShortEventKey ¶
func GetShortEventKey(event slack.MessageEvent) string
GetShortEventKey builds a key over user-channel
func ParseDuration ¶
ParseDuration also allowes other duration modifier like "min" or "sec" e.g. 12min10sec -> 12m10s
Example ¶
fmt.Println(ParseDuration("12min1sec"))
Output: 12m1s <nil>
func RegexpResultToParams ¶
RegexpResultToParams converts a regexp result into a simple string map...kind of deprecated
func RegisterFunctions ¶
RegisterFunctions will add a function to any template renderer