From 0462c96a5a9da3e8adc78d96acd39575a8b46c40 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Bj=C3=B8rn=20Erik=20Pedersen?= Date: Fri, 8 Sep 2017 14:16:21 +0200 Subject: tpl/compare: Add cond (ternary) template func Fixes #3860 --- tpl/compare/compare_test.go | 9 +++++++++ 1 file changed, 9 insertions(+) (limited to 'tpl/compare/compare_test.go') diff --git a/tpl/compare/compare_test.go b/tpl/compare/compare_test.go index 9adbcf574..c9bc2ffe9 100644 --- a/tpl/compare/compare_test.go +++ b/tpl/compare/compare_test.go @@ -221,3 +221,12 @@ func TestTimeUnix(t *testing.T) { toTimeUnix(iv) }(t) } + +func TestConditional(t *testing.T) { + assert := require.New(t) + n := New() + a, b := "a", "b" + + assert.Equal(a, n.Conditional(true, a, b)) + assert.Equal(b, n.Conditional(false, a, b)) +} -- cgit v1.2.3