Add utility functions for filtering results and rename templates

This commit is contained in:
Simon Marsh 2021-01-12 10:15:54 +00:00
parent 66e63c66a1
commit 600bafe08d
Signed by: burble
GPG Key ID: 0FCCD13AE1CF7ED8
6 changed files with 12 additions and 1 deletions

View File

@ -1,6 +1,7 @@
package main
import (
"strings"
"text/template"
)
@ -42,6 +43,16 @@ type SummaryRowData struct {
Info string
}
// utility functions to allow filtering of results in the template
func (r SummaryRowData) NameHasPrefix(prefix string) bool {
return strings.HasPrefix(r.Name, prefix)
}
func (r SummaryRowData) NameContains(prefix string) bool {
return strings.Contains(r.Name, prefix)
}
type TemplateSummary struct {
ServerName string
Raw string
@ -94,7 +105,7 @@ func ImportTemplates() {
for _, tmpl := range requiredTemplates {
// extract the template definition from the bindata
def := MustAssetString("templates/" + tmpl)
def := MustAssetString("templates/" + tmpl + ".tpl")
// and add it to the template library
template, err := template.New(tmpl).Parse(def)