Browse Source

Added toUpper and toLower formatting to templates

pull/1894/head
Dmitry Ulianov 8 years ago
parent
commit
a8619111f3
  1. 2
      template/template.go
  2. 10
      template/template_test.go

2
template/template.go

@ -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 {

10
template/template_test.go

@ -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\" }}",

Loading…
Cancel
Save