templ generate fails on a large file
Author: diyor28Created Jan 17, 2025Updated Jul 24, 2026
Describe the Bug
The templ generate command fails to generate .go code for a large file, citing syntax errors. However, when the file is divided into smaller parts, the generation works without any issues.
To Reproduce
Steps to reproduce the behavior:
- Run
templ generateon the following file: Gist Link - Observe the error output.
Expected Behavior
The .go code should be generated successfully without errors, even for large files.
Screenshots
Logs
templ generate
(✗) Error [ error=failed to generate code for "/Users/diyorkhaydarov/Projects/sdk/icons/icons.templ": /Users/diyorkhaydarov/Projects/sdk/icons/icons.templ parsing error: templ: malformed templ expression, expected `templ functionName() {`: line 20, col 0 ]
(✗) Command failed: generation completed with 1 errorstempl info Output
(✓) os [ goos=darwin goarch=arm64 ]
(✓) go [ location=/opt/homebrew/bin/go version=go version go1.23.2 darwin/arm64 ]
(✓) gopls [ location=/Users/diyorkhaydarov/go/bin/gopls version=golang.org/x/tools/gopls v0.17.1 ]
(✓) templ [ location=/Users/diyorkhaydarov/go/bin/templ version=v0.3.819 ]Source: a-h/templ