Skip to content

Commit

Permalink
Fixes small bug whereby path was sometimes incorrectly set
Browse files Browse the repository at this point in the history
  • Loading branch information
gwynforthewyn committed Apr 22, 2024
1 parent 5c020aa commit 8147c55
Show file tree
Hide file tree
Showing 2 changed files with 5 additions and 5 deletions.
1 change: 1 addition & 0 deletions .gitignore
Original file line number Diff line number Diff line change
Expand Up @@ -3,3 +3,4 @@ scratch_templ_dir
**/templ
templ
templ-config-files
.vscode
9 changes: 4 additions & 5 deletions templates/templates.go
Original file line number Diff line number Diff line change
Expand Up @@ -51,7 +51,7 @@ func FindTemplateAndVariableFiles(argv []string) ([]string, map[string]string, e
var templateFilePaths = make([]string, 0)
var templateVariablesFilesPaths = make(map[string]string, 0)

for _, path := range argv {
for _, template := range argv {
// The arguments at this point either read as a name/of/template_file, or as name/of/template_file=path/to/variables.
// In the first case, I want to store the path to the template file in an array to hand in to the renderFromFiles command.
// In the second case, we store the path to the template file in the same array, and also use that path as an
Expand All @@ -60,12 +60,11 @@ func FindTemplateAndVariableFiles(argv []string) ([]string, map[string]string, e
// interrogate each path from args to split into either a set of strings or a path+string
// then use findFilesByName to find the templates associated with those strings
variablesFile := false
var template string
var templateVariablesPath string

if strings.Contains(path, "=") {
if strings.Contains(template, "=") {
variablesFile = true
templateAndVariablesPath := strings.Split(path, "=")
templateAndVariablesPath := strings.Split(template, "=")
template = templateAndVariablesPath[0]
templateVariablesPath = templateAndVariablesPath[1]
}
Expand Down Expand Up @@ -108,7 +107,7 @@ func RenderFromFiles(templateFiles []string, templateVariables map[string]string

// No variables? Just print and move on.
if templateVariablesFilePath == "" {
content, err := os.ReadFile(templatePath)
content, err := os.ReadFile(string(templatePath))

if err != nil {
_, file, line, _ := runtime.Caller(0)
Expand Down

0 comments on commit 8147c55

Please sign in to comment.