Skip to content

Commit

Permalink
add template helper functions, remove utils
Browse files Browse the repository at this point in the history
  • Loading branch information
StarpTech committed Jan 21, 2018
1 parent 66ac86c commit d075c93
Show file tree
Hide file tree
Showing 2 changed files with 11 additions and 18 deletions.
15 changes: 11 additions & 4 deletions commands/template.go
Original file line number Diff line number Diff line change
Expand Up @@ -14,7 +14,7 @@ import (
logy "github.com/apex/log"
"github.com/briandowns/spinner"
"github.com/netzkern/butler/config"
"github.com/netzkern/butler/util"
"github.com/pinzolo/casee"
survey "gopkg.in/AlecAivazis/survey.v1"
git "gopkg.in/src-d/go-git.v4"
)
Expand Down Expand Up @@ -128,7 +128,7 @@ func (t *Templating) prompts() (*ProjectData, error) {
return nil, err
}

project.Name = util.NormalizeProjectName(project.Name)
project.Name = casee.ToPascalCase(project.Name)

return project, nil
}
Expand Down Expand Up @@ -214,8 +214,15 @@ func (t *Templating) Run() error {

var b bytes.Buffer

tmpl, err := template.New(path).Delims(startDelim, endDelim).Parse(string(dat))
tmplPath, err := template.New(path).Delims(startDelim, endDelim).Parse(path)
utilFuncMap := template.FuncMap{
"toCamelCase": casee.ToCamelCase,
"toPascalCase": casee.ToPascalCase,
"toSnakeCase": casee.ToSnakeCase,
}

tmpl, err := template.New(path).Delims(startDelim, endDelim).Funcs(utilFuncMap).Parse(string(dat))

tmplPath, err := template.New(path).Delims(startDelim, endDelim).Funcs(utilFuncMap).Parse(path)

err = tmplPath.Execute(&b, templateData)

Expand Down
14 changes: 0 additions & 14 deletions util/util.go

This file was deleted.

0 comments on commit d075c93

Please sign in to comment.