templ ships with hot reload. Since
rjeczalik/notify filesystem watchers struggle to provide a working cross-platform behaviour, templ uses a basic
os.WalkDir function to iterate through
*.templ files on disk, and uses a backoff strategy to prevent excessive disk thrashing and reduce CPU usage.
templ generate --watch will watch the current directory and will templ files if changes are detected.
--cmd argument is set, templ start or restart the command once template code generation is complete.
--proxy argument is set, templ will start a HTTP proxy pointed at the given address. The proxy rewrites HTML received from the given address and adds a script just before the
templ generate --watch --proxy="http://localhost:8080" --cmd="runtest"
Air's reload performance is better due to its complex filesystem notification setup, but doens't ship with a proxy to automatically reload pages, and requires a
toml configuration file for operation.
See https://github.com/cosmtrek/air for details.
root = "."
tmp_dir = "tmp"
bin = "./tmp/main"
cmd = "templ generate && go build -o ./tmp/main ."
delay = 1000
exclude_dir = ["assets", "tmp", "vendor"]
exclude_file = 
exclude_regex = [".*_templ.go"]
exclude_unchanged = false
follow_symlink = false
full_bin = ""
include_dir = 
include_ext = ["go", "tpl", "tmpl", "templ", "html"]
kill_delay = "0s"
log = "build-errors.log"
send_interrupt = false
stop_on_error = true
app = ""
build = "yellow"
main = "magenta"
runner = "green"
watcher = "cyan"
time = false
clean_on_exit = false