From 7f07a947a303f453d94125b5479aa76545626ee4 Mon Sep 17 00:00:00 2001 From: Andrea Fazzi Date: Tue, 28 Jan 2020 08:58:00 +0100 Subject: [PATCH] Create version template helper --- VERSION | 2 +- renderer/funcmap.go | 10 ++++++++++ 2 files changed, 11 insertions(+), 1 deletion(-) diff --git a/VERSION b/VERSION index a3427528..1296e0f5 100644 --- a/VERSION +++ b/VERSION @@ -1 +1 @@ -0.1.0-3-gf576e74 +0.1.0-4-gf49236b diff --git a/renderer/funcmap.go b/renderer/funcmap.go index 7bf77cfa..2549d4ed 100644 --- a/renderer/funcmap.go +++ b/renderer/funcmap.go @@ -4,6 +4,7 @@ import ( "errors" "fmt" "html/template" + "io/ioutil" "net/url" "reflect" "strconv" @@ -22,6 +23,7 @@ const ( var ( funcMap = template.FuncMap{ + "version": version, "toInt": toInt, "isResponseIn": isResponseIn, "query": query, @@ -65,6 +67,14 @@ var ( } ) +func version() string { + version, err := ioutil.ReadFile("./VERSION") + if err != nil { + return "" + } + return string(version) +} + func toInt(value float64) int { return int(value) }