Skip to content

Commit

Permalink
Add some comments
Browse files Browse the repository at this point in the history
  • Loading branch information
stephenafamo committed Dec 27, 2023
1 parent 7945dfd commit ceecccb
Showing 1 changed file with 2 additions and 0 deletions.
2 changes: 2 additions & 0 deletions cmd/templ/generatecmd/main.go
Original file line number Diff line number Diff line change
Expand Up @@ -447,6 +447,7 @@ func generate(ctx context.Context, basePath, fileName string, hashes map[string]
return nil, fmt.Errorf("%s source formatting error: %w", fileName, err)
}

// Hash and write the file if the hash has changed
hash := md5.Sum(data)
if hashes[targetFileName] != hash {
if err = os.WriteFile(targetFileName, data, 0o644); err != nil {
Expand All @@ -455,6 +456,7 @@ func generate(ctx context.Context, basePath, fileName string, hashes map[string]
hashes[targetFileName] = hash
}

// Add the txt file if it has changed
if len(literals) > 0 {
txtFileName := strings.TrimSuffix(fileName, ".templ") + "_templ.txt"
contents := strings.Join(literals, "\n")
Expand Down

0 comments on commit ceecccb

Please sign in to comment.