From 2ab581a1d693311783cc6a93de8aa24aad831006 Mon Sep 17 00:00:00 2001 From: Mathieu Acthernoene Date: Thu, 15 Dec 2016 12:22:23 +0100 Subject: [PATCH] Add first & last helpers --- encoder.go | 6 ++++++ 1 file changed, 6 insertions(+) diff --git a/encoder.go b/encoder.go index d0c0cdd..330370c 100644 --- a/encoder.go +++ b/encoder.go @@ -29,6 +29,12 @@ var ProtoHelpersFuncMap = template.FuncMap{ a, _ := json.MarshalIndent(v, "", " ") return string(a) }, + "first": func(a []string) string { + return a[0] + }, + "last": func(a []string) string { + return a[len(a)-1] + }, } type GenericTemplateBasedEncoder struct {