about summary refs log tree commit diff
path: root/templater/templater.go
diff options
context:
space:
mode:
authorVincent Ambo <tazjin@gmail.com>2017-04-04T09·02+0200
committerVincent Ambo <tazjin@gmail.com>2017-04-04T09·05+0200
commit3b0f41e71d8ff2763ee827d17034b5d929d0c7ff (patch)
tree637f1028a3831a409cb98682edc00c477574d66e /templater/templater.go
parent45aee8257fd5bb947cb127cd645d8ab571a15379 (diff)
feat templater: Fail if values are missing
Golang's template package now has an option for failing if template variables
are missing: https://golang.org/pkg/text/template/#Template.Option

This updates the templater code to make use of that option and return the
errors encountered during templating.

This fixes #1
Diffstat (limited to 'templater/templater.go')
-rw-r--r--templater/templater.go4
1 files changed, 3 insertions, 1 deletions
diff --git a/templater/templater.go b/templater/templater.go
index e6f8a92ee3a1..e9e8c11e927a 100644
--- a/templater/templater.go
+++ b/templater/templater.go
@@ -16,6 +16,8 @@ import (
 	"github.com/tazjin/kontemplate/util"
 )
 
+const failOnMissingKeys string = "missingkey=error"
+
 // Error that is caused by non-existent template files being specified
 type TemplateNotFoundError struct {
 	meep.AllTraits
@@ -78,7 +80,7 @@ func processFiles(c *context.Context, rs *context.ResourceSet, rp string, files
 }
 
 func templateFile(c *context.Context, rs *context.ResourceSet, filename string) (string, error) {
-	tpl, err := template.New(path.Base(filename)).Funcs(templateFuncs()).ParseFiles(filename)
+	tpl, err := template.New(path.Base(filename)).Funcs(templateFuncs()).Option(failOnMissingKeys).ParseFiles(filename)
 
 	if err != nil {
 		return "", meep.New(