Skip to content

Commit

Permalink
Merge pull request #5 from hairyhenderson/new-tests
Browse files Browse the repository at this point in the history
💄 slight refactoring & adding some vague unit tests...
  • Loading branch information
hairyhenderson committed Jan 24, 2016
2 parents af7f895 + ccdeae5 commit 7453805
Showing 1 changed file with 8 additions and 2 deletions.
10 changes: 8 additions & 2 deletions main.go
Original file line number Diff line number Diff line change
Expand Up @@ -23,15 +23,21 @@ func init() {
}
}

func createTemplate() *template.Template {
return template.New("template").Option("missingkey=error")
}

// RunTemplate -
func RunTemplate(in io.Reader, out io.Writer) {
s := bufio.NewScanner(in)
context := &Context{}
for s.Scan() {
tmpl, err := template.New("template").Option("missingkey=error").Parse(s.Text())
tmpl, err := createTemplate().Parse(s.Text())
if err != nil {
log.Fatalf("Line %q: %v\n", s.Text(), err)
}

if err := tmpl.Execute(out, &Context{}); err != nil {
if err := tmpl.Execute(out, context); err != nil {
panic(err)
}
out.Write([]byte("\n"))
Expand Down

0 comments on commit 7453805

Please sign in to comment.