* Add date and tz functions to templates
This commit adds the date and tz functions to templates. This means
users can now format time in a specified format and also change
the timezone to their specific locale.
An example of how these functions work, and can be composed together,
can be seen here:
{{ .StartsAt | tz "Europe/Paris" | date "15:04:05 MST" }}
Signed-off-by: George Robinson <george.robinson@grafana.com>
---------
Signed-off-by: George Robinson <george.robinson@grafana.com>
This commit fixes data corruption in templates that use the title
function as it used a shared cases.Title when casers should not
be shared between goroutines. When templates that used the title
function were executed at the same time, data corruption would occur
in the text that was being cased. This is fixed using a separate
caser for each function call.
Add tests to assertDefaultFuncs are thread-safe
Signed-off-by: George Robinson <george.robinson@grafana.com>
This commit implements the Stringer interface for Pairs and KVs.
It changes how Pairs are printed in templates from
map[name1:value1 name2:value2] to name1=value1, name2=value2. KVs
work similar, but are first sorted into pairs before being printed.
Signed-off-by: George Robinson <george.robinson@grafana.com>
Since it's impossible to create a string slice in a Go template by
default, add a function to work around this problem.
The use case is to make it easy to call KV.Remove with an arbitrary
slice inside a template.
Signed-off-by: Vincent Rischmann <vincent@rischmann.fr>