Documentation
¶
Overview ¶
templgofilereg solves a very peculiar task. It provides a comparer that keeps track of generated `_templ.go` files given to it and tells whether the recent changes to it require Templiér to recompile and restart the application server because the internal Go code has changed.
In dev mode, Templ uses `_templ.txt` files to allow for fast reloads that don't require server recompilation, but Templiér can't know when to just refresh the tab and when to actually recompile because Templ always changes the `_templ.go` file. However, when it only changes the text argument to `templruntime.WriteString` we can tell we don't need recompilation and a tab refresh is enough.
Index ¶
Constants ¶
This section is empty.
Variables ¶
This section is empty.
Functions ¶
This section is empty.
Types ¶
type Comparer ¶
type Comparer struct {
// contains filtered or unexported fields
}
Comparer compares the generated `_templ.go` that Templ generates to its previous version passed to Compare and attempts to detect whether a server recompilation is necessary.
func (*Comparer) Compare ¶
Compare returns recompile=true if the _templ.go file under filePath changed in a way that requires the server to be recompiled. Otherwise the file only changed the text arguments in calls to templruntime.WriteString which means that the change can be reflected by _templ.txt fast reload dev file. Compare always returns recompile=true if the file is new.