From a8619111f3ad54f9dcadfa0a1ff5d03e577a958c Mon Sep 17 00:00:00 2001 From: Dmitry Ulianov Date: Mon, 15 Aug 2016 14:00:22 +0300 Subject: [PATCH] Added toUpper and toLower formatting to templates --- template/template.go | 2 ++ template/template_test.go | 10 ++++++++++ 2 files changed, 12 insertions(+) diff --git a/template/template.go b/template/template.go index e06e26d82..a1d6cfe06 100644 --- a/template/template.go +++ b/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 { diff --git a/template/template_test.go b/template/template_test.go index 900dd6f96..bab51d651 100644 --- a/template/template_test.go +++ b/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\" }}",