Skip to content

Commit

Permalink
Fix template_file (#9)
Browse files Browse the repository at this point in the history
  • Loading branch information
aknysh authored Jan 9, 2019
1 parent 07b4781 commit b54f771
Show file tree
Hide file tree
Showing 2 changed files with 5 additions and 3 deletions.
2 changes: 1 addition & 1 deletion LICENSE
Original file line number Diff line number Diff line change
Expand Up @@ -186,7 +186,7 @@
same "printed page" as the copyright notice for easier
identification within third-party archives.

Copyright 2018 Cloud Posse, LLC
Copyright 2018-2019 Cloud Posse, LLC

Licensed under the Apache License, Version 2.0 (the "License");
you may not use this file except in compliance with the License.
Expand Down
6 changes: 4 additions & 2 deletions main.go
Original file line number Diff line number Diff line change
Expand Up @@ -12,6 +12,7 @@ import (
"log"
"net/http"
"os"
"path"
"regexp"
"strconv"
"text/template"
Expand Down Expand Up @@ -105,23 +106,24 @@ func formatComment(comment string) (string, error) {
var templateFileFinal string

if *format != "" || *templ != "" {
t = template.New("formatComment").Funcs(sprig.TxtFuncMap())
if *templ != "" {
templateFinal = *templ
} else {
templateFinal = *format
}
t = template.New("formatComment").Funcs(sprig.TxtFuncMap())
t, err = t.Parse(templateFinal)
if err != nil {
return "", err
}
} else {
t = template.New("formatComment").Funcs(sprig.TxtFuncMap())
if *templateFile != "" {
templateFileFinal = *templateFile
} else {
templateFileFinal = *formatFile
}
name := path.Base(templateFileFinal)
t = template.New(name).Funcs(sprig.TxtFuncMap())
t, err = t.ParseFiles(templateFileFinal)
if err != nil {
return "", err
Expand Down

0 comments on commit b54f771

Please sign in to comment.