mirror of
https://github.com/ralsina/tartrazine.git
synced 2025-06-19 14:43:05 -03:00
changes in the API, ready to version 2
This commit is contained in:
@ -3,6 +3,7 @@ package generator
|
||||
import (
|
||||
"bytes"
|
||||
"io"
|
||||
"strings"
|
||||
"text/template"
|
||||
|
||||
yaml "gopkg.in/yaml.v2"
|
||||
@ -25,20 +26,21 @@ func Filenames(data []byte, filenamesTmplPath, filenamesTmplName, commit string)
|
||||
return buf.Bytes(), nil
|
||||
}
|
||||
|
||||
func buildFilenameLanguageMap(languages map[string]*languageInfo) map[string]string {
|
||||
filenameLangMap := make(map[string]string)
|
||||
func buildFilenameLanguageMap(languages map[string]*languageInfo) map[string][]string {
|
||||
filenameLangMap := make(map[string][]string)
|
||||
for lang, langInfo := range languages {
|
||||
for _, filename := range langInfo.Filenames {
|
||||
filenameLangMap[filename] = lang
|
||||
filenameLangMap[filename] = append(filenameLangMap[filename], lang)
|
||||
}
|
||||
}
|
||||
|
||||
return filenameLangMap
|
||||
}
|
||||
|
||||
func executeFilenamesTemplate(out io.Writer, languagesByFilename map[string]string, filenamesTmplPath, filenamesTmpl, commit string) error {
|
||||
func executeFilenamesTemplate(out io.Writer, languagesByFilename map[string][]string, filenamesTmplPath, filenamesTmpl, commit string) error {
|
||||
fmap := template.FuncMap{
|
||||
"getCommit": func() string { return commit },
|
||||
"getCommit": func() string { return commit },
|
||||
"formatStringSlice": func(slice []string) string { return `"` + strings.Join(slice, `","`) + `"` },
|
||||
}
|
||||
|
||||
t := template.Must(template.New(filenamesTmpl).Funcs(fmap).ParseFiles(filenamesTmplPath))
|
||||
|
Reference in New Issue
Block a user