Merge pull request #1894 from d-ulyanov/annotations-formatting

Added toUpper and toLower formatting to templates
This commit is contained in:
Fabian Reinartz 2016-08-15 18:19:05 +02:00 committed by GitHub
commit 6bfd30269a
2 changed files with 12 additions and 0 deletions

View file

@ -150,6 +150,8 @@ func NewTemplateExpander(text string, name string, data interface{}, timestamp m
},
"match": regexp.MatchString,
"title": strings.Title,
"toUpper": strings.ToUpper,
"toLower": strings.ToLower,
"graphLink": strutil.GraphLinkForExpression,
"tableLink": strutil.TableLinkForExpression,
"sortByLabel": func(label string, v queryResult) queryResult {

View file

@ -164,6 +164,16 @@ func TestTemplateExpansion(t *testing.T) {
text: "{{ \"aa bb CC\" | title }}",
output: "Aa Bb CC",
},
{
// toUpper.
text: "{{ \"aa bb CC\" | toUpper }}",
output: "AA BB CC",
},
{
// toLower.
text: "{{ \"aA bB CC\" | toLower }}",
output: "aa bb cc",
},
{
// Match.
text: "{{ match \"a+\" \"aa\" }} {{ match \"a+\" \"b\" }}",