@@ -21,6 +21,7 @@ import (
21
21
"github.com/a-h/templ/cmd/templ/visualize"
22
22
"github.com/a-h/templ/generator"
23
23
"github.com/a-h/templ/parser/v2"
24
+ "github.com/a-h/templ/runtime"
24
25
"github.com/fsnotify/fsnotify"
25
26
)
26
27
@@ -118,20 +119,6 @@ func (h *FSEventHandler) HandleEvent(ctx context.Context, event fsnotify.Event)
118
119
}
119
120
return GenerateResult {Updated : true , GoUpdated : true , TextUpdated : false }, nil
120
121
}
121
- // Handle _templ.txt files.
122
- if ! event .Has (fsnotify .Remove ) && strings .HasSuffix (event .Name , "_templ.txt" ) {
123
- if h .devMode {
124
- // Don't delete the file in dev mode, ignore changes to it, since the .templ file
125
- // must have been updated in order to trigger a change in the _templ.txt file.
126
- return GenerateResult {Updated : false , GoUpdated : false , TextUpdated : false }, nil
127
- }
128
- h .Log .Debug ("Deleting watch mode file" , slog .String ("file" , event .Name ))
129
- if err = os .Remove (event .Name ); err != nil {
130
- h .Log .Warn ("Failed to remove watch mode text file" , slog .Any ("error" , err ))
131
- return GenerateResult {}, nil
132
- }
133
- return GenerateResult {}, nil
134
- }
135
122
136
123
// If the file hasn't been updated since the last time we processed it, ignore it.
137
124
lastModTime , updatedModTime := h .UpsertLastModTime (event .Name )
@@ -274,7 +261,8 @@ func (h *FSEventHandler) generate(ctx context.Context, fileName string) (result
274
261
275
262
// Add the txt file if it has changed.
276
263
if h .devMode {
277
- txtFileName := strings .TrimSuffix (fileName , ".templ" ) + "_templ.txt"
264
+ txtFileName := runtime .GetDevModeTextFileName (fileName )
265
+ h .Log .Debug ("Writing development mode text file" , slog .String ("file" , fileName ), slog .String ("output" , txtFileName ))
278
266
joined := strings .Join (generatorOutput .Literals , "\n " )
279
267
txtHash := sha256 .Sum256 ([]byte (joined ))
280
268
if h .UpsertHash (txtFileName , txtHash ) {
0 commit comments