Skip to content

Commit

Permalink
Fixed self-rendering error handling
Browse files Browse the repository at this point in the history
  • Loading branch information
dcwangmit01 committed Aug 20, 2018
1 parent e600817 commit 532abbe
Showing 1 changed file with 4 additions and 4 deletions.
8 changes: 4 additions & 4 deletions mhlib/app.go
Original file line number Diff line number Diff line change
Expand Up @@ -311,7 +311,7 @@ func selfRender(templateValuesStr string, enableGomplate bool) (string, error) {
// Unmarshal the file as a values dict
vals := Values{}
err := yaml.Unmarshal([]byte(templateValuesStr), &vals)
if err != nil { panic(err) }
if err != nil { return "", err }

tmpl := template.New("SelfTemplate")
tmpl.Delims("[[", "]]")
Expand All @@ -336,7 +336,7 @@ func selfRender(templateValuesStr string, enableGomplate bool) (string, error) {

// Access gomplate datasources and function library
d, err := data.NewData(dataSources, dataSourceHeaders)
if err != nil { panic(err) }
if err != nil { return "", err }

// Configure go/text/template to use gomplate
// datasources and function library.
Expand All @@ -347,10 +347,10 @@ func selfRender(templateValuesStr string, enableGomplate bool) (string, error) {
// Run the the file through the tempating engine as both values
// file and template file
tmpl.Parse(string(templateValuesStr))
if err != nil { panic(err) }
if err != nil { return "", err }
out := new(bytes.Buffer)
err = tmpl.Execute(out, vals)
if err != nil { panic(err) }
if err != nil { return "", err }

newRender := out.String()
if lastRender == newRender {
Expand Down

0 comments on commit 532abbe

Please sign in to comment.