Full Code of a-h/templ for AI

main 009ec8882996 cached
833 files
3.3 MB
908.5k tokens
3138 symbols
1 requests
Download .txt
Showing preview only (3,618K chars total). Download the full file or copy to clipboard to get everything.
Repository: a-h/templ
Branch: main
Commit: 009ec8882996
Files: 833
Total size: 3.3 MB

Directory structure:
gitextract_x0_4cpga/

├── .dockerignore
├── .envrc
├── .github/
│   ├── FUNDING.yml
│   ├── ISSUE_TEMPLATE/
│   │   └── bug_report.md
│   ├── copilot-instructions.md
│   └── workflows/
│       ├── ci.yml
│       ├── docs.yaml
│       ├── flakehub-publish-tagged.yml
│       └── release.yml
├── .gitignore
├── .goreleaser.yaml
├── .ignore
├── .version
├── CODE_OF_CONDUCT.md
├── CONTRIBUTING.md
├── LICENSE
├── README.md
├── SECURITY.md
├── benchmarks/
│   ├── react/
│   │   ├── .gitignore
│   │   ├── README.md
│   │   ├── package.json
│   │   └── src/
│   │       └── index.jsx
│   └── templ/
│       ├── README.md
│       ├── data.go
│       ├── render_test.go
│       ├── template.templ
│       └── template_templ.go
├── cfg/
│   └── cfg.go
├── cmd/
│   └── templ/
│       ├── fmtcmd/
│       │   ├── main.go
│       │   ├── main_test.go
│       │   └── testdata.txtar
│       ├── generatecmd/
│       │   ├── cmd.go
│       │   ├── eventhandler.go
│       │   ├── fatalerror.go
│       │   ├── main.go
│       │   ├── main_test.go
│       │   ├── modcheck/
│       │   │   ├── modcheck.go
│       │   │   └── modcheck_test.go
│       │   ├── proxy/
│       │   │   ├── proxy.go
│       │   │   ├── proxy_test.go
│       │   │   └── script.js
│       │   ├── run/
│       │   │   ├── run_test.go
│       │   │   ├── run_unix.go
│       │   │   ├── run_windows.go
│       │   │   └── testprogram/
│       │   │       ├── go.mod.embed
│       │   │       └── main.go
│       │   ├── sse/
│       │   │   └── server.go
│       │   ├── symlink/
│       │   │   └── symlink_test.go
│       │   ├── test-eventhandler/
│       │   │   ├── eventhandler_test.go
│       │   │   ├── multiple_errors.templ.error
│       │   │   └── single_error.templ.error
│       │   ├── testwatch/
│       │   │   ├── generate_test.go
│       │   │   └── testdata/
│       │   │       ├── go.mod.embed
│       │   │       ├── go.sum
│       │   │       ├── main.go
│       │   │       ├── templates.templ
│       │   │       └── templates_templ.go
│       │   └── watcher/
│       │       ├── watch.go
│       │       └── watch_test.go
│       ├── infocmd/
│       │   └── main.go
│       ├── lspcmd/
│       │   ├── httpdebug/
│       │   │   ├── handler.go
│       │   │   ├── list.templ
│       │   │   └── list_templ.go
│       │   ├── lsp_test.go
│       │   ├── lspdiff/
│       │   │   └── lspdiff.go
│       │   ├── main.go
│       │   ├── pls/
│       │   │   └── main.go
│       │   ├── proxy/
│       │   │   ├── client.go
│       │   │   ├── diagnosticcache.go
│       │   │   ├── documentcontents.go
│       │   │   ├── documentcontents_test.go
│       │   │   ├── import_test.go
│       │   │   ├── rewrite.go
│       │   │   ├── server.go
│       │   │   ├── snippets.go
│       │   │   ├── sourcemapcache.go
│       │   │   └── sourcemapcache_test.go
│       │   └── stdrwc.go
│       ├── main.go
│       ├── main_test.go
│       ├── processor/
│       │   ├── processor.go
│       │   └── processor_test.go
│       ├── sloghandler/
│       │   └── handler.go
│       ├── testproject/
│       │   ├── testdata/
│       │   │   ├── css-classes/
│       │   │   │   └── classes.go
│       │   │   ├── go.mod.embed
│       │   │   ├── go.sum
│       │   │   ├── main.go
│       │   │   ├── remotechild.templ
│       │   │   ├── remotechild_templ.go
│       │   │   ├── remoteparent.templ
│       │   │   ├── remoteparent_templ.go
│       │   │   ├── templates.templ
│       │   │   └── templates_templ.go
│       │   └── testproject.go
│       └── visualize/
│           ├── sourcemapvisualisation.templ
│           ├── sourcemapvisualisation_templ.go
│           └── types.go
├── cosign.pub
├── docs/
│   ├── .gitignore
│   ├── README.md
│   ├── babel.config.js
│   ├── docs/
│   │   ├── 02-quick-start/
│   │   │   ├── 01-installation.md
│   │   │   ├── 02-creating-a-simple-templ-component.md
│   │   │   ├── 03-running-your-first-templ-application.md
│   │   │   └── _category_.json
│   │   ├── 03-syntax-and-usage/
│   │   │   ├── 01-basic-syntax.md
│   │   │   ├── 02-elements.md
│   │   │   ├── 03-attributes.md
│   │   │   ├── 04-expressions.md
│   │   │   ├── 05-statements.md
│   │   │   ├── 06-if-else.md
│   │   │   ├── 07-switch.md
│   │   │   ├── 08-loops.md
│   │   │   ├── 09-raw-go.md
│   │   │   ├── 10-template-composition.md
│   │   │   ├── 11-forms.md
│   │   │   ├── 12-css-style-management.md
│   │   │   ├── 13-script-templates.md
│   │   │   ├── 14-comments.md
│   │   │   ├── 15-context.md
│   │   │   ├── 16-using-with-go-templates.md
│   │   │   ├── 17-rendering-raw-html.md
│   │   │   ├── 18-render-once.md
│   │   │   ├── 19-fragments.md
│   │   │   ├── 20-using-react-with-templ.md
│   │   │   └── _category_.json
│   │   ├── 04-core-concepts/
│   │   │   ├── 01-components.md
│   │   │   ├── 02-template-generation.md
│   │   │   ├── 03-testing.md
│   │   │   ├── 04-view-models.md
│   │   │   └── _category_.json
│   │   ├── 05-server-side-rendering/
│   │   │   ├── 01-creating-an-http-server-with-templ.md
│   │   │   ├── 02-example-counter-application.md
│   │   │   ├── 03-htmx.md
│   │   │   ├── 04-datastar.md
│   │   │   ├── 05-streaming.md
│   │   │   └── _category_.json
│   │   ├── 06-static-rendering/
│   │   │   ├── 01-generating-static-html-files-with-templ.md
│   │   │   ├── 02-blog-example.md
│   │   │   ├── 03-deploying-static-files.md
│   │   │   └── _category_.json
│   │   ├── 07-project-structure/
│   │   │   ├── 01-project-structure.md
│   │   │   └── _category_.json
│   │   ├── 08-hosting-and-deployment/
│   │   │   ├── 01-hosting-on-aws-lambda.md
│   │   │   ├── 02-hosting-using-docker.md
│   │   │   └── _category_.json
│   │   ├── 09-developer-tools/
│   │   │   ├── 01-cli.md
│   │   │   ├── 02-ide-support.md
│   │   │   ├── 03-live-reload.md
│   │   │   ├── 04-live-reload-with-other-tools.md
│   │   │   ├── 05-llm.md
│   │   │   ├── 06-cicd.md
│   │   │   └── _category_.json
│   │   ├── 10-security/
│   │   │   ├── 01-injection-attacks.md
│   │   │   ├── 02-content-security-policy.md
│   │   │   ├── 03-code-signing.md
│   │   │   └── _category_.json
│   │   ├── 11-media/
│   │   │   ├── _category_.json
│   │   │   └── index.md
│   │   ├── 12-integrations/
│   │   │   ├── 01-web-frameworks.md
│   │   │   ├── 02-internationalization.md
│   │   │   └── _category_.json
│   │   ├── 13-experimental/
│   │   │   ├── 01-overview.md
│   │   │   ├── 02-urlbuilder.md
│   │   │   └── _category_.json
│   │   ├── 14-help-and-community/
│   │   │   ├── _category_.json
│   │   │   └── index.md
│   │   ├── 15-component-libraries/
│   │   │   ├── _category_.json
│   │   │   └── index.md
│   │   ├── 16-faq/
│   │   │   ├── _category_.json
│   │   │   └── index.md
│   │   ├── go.mod
│   │   ├── go.sum
│   │   ├── index.md
│   │   └── main.go
│   ├── docusaurus.config.js
│   ├── package.json
│   ├── sidebars.js
│   ├── src/
│   │   ├── css/
│   │   │   └── custom.css
│   │   └── theme/
│   │       └── prism-include-languages.js
│   └── static/
│       ├── .nojekyll
│       └── img/
│           └── shadowdom.webm
├── examples/
│   ├── blog/
│   │   ├── go.mod
│   │   ├── go.sum
│   │   ├── main.go
│   │   ├── posts.templ
│   │   ├── posts_templ.go
│   │   └── posts_test.go
│   ├── content-security-policy/
│   │   ├── main.go
│   │   ├── templates.templ
│   │   └── templates_templ.go
│   ├── counter/
│   │   ├── Dockerfile
│   │   ├── README.md
│   │   ├── assets/
│   │   │   ├── css/
│   │   │   │   └── bulma.css
│   │   │   └── favicon/
│   │   │       ├── about.txt
│   │   │       └── site.webmanifest
│   │   ├── cdk/
│   │   │   ├── .gitignore
│   │   │   ├── cdk.json
│   │   │   └── stack.go
│   │   ├── components/
│   │   │   ├── components.templ
│   │   │   └── components_templ.go
│   │   ├── db/
│   │   │   └── db.go
│   │   ├── go.mod
│   │   ├── go.sum
│   │   ├── handlers/
│   │   │   └── default.go
│   │   ├── lambda/
│   │   │   └── main.go
│   │   ├── main.go
│   │   ├── services/
│   │   │   └── count.go
│   │   └── session/
│   │       └── session.go
│   ├── counter-basic/
│   │   ├── .dockerignore
│   │   ├── Dockerfile
│   │   ├── README.md
│   │   ├── assets/
│   │   │   ├── bulma.css
│   │   │   └── favicon/
│   │   │       ├── about.txt
│   │   │       └── site.webmanifest
│   │   ├── components.templ
│   │   ├── components_templ.go
│   │   ├── fly.toml
│   │   ├── go.mod
│   │   ├── go.sum
│   │   └── main.go
│   ├── external-libraries/
│   │   ├── components.templ
│   │   ├── components_templ.go
│   │   ├── go.mod
│   │   ├── go.sum
│   │   └── main.go
│   ├── hello-world-ssr/
│   │   ├── hello.templ
│   │   ├── hello_templ.go
│   │   └── main.go
│   ├── hello-world-static/
│   │   ├── hello.templ
│   │   ├── hello_templ.go
│   │   └── main.go
│   ├── htmx-fragments/
│   │   ├── README.md
│   │   ├── go.mod
│   │   ├── go.sum
│   │   ├── main.templ
│   │   └── main_templ.go
│   ├── integration-chi/
│   │   ├── go.mod
│   │   ├── go.sum
│   │   ├── home.templ
│   │   ├── home_templ.go
│   │   └── main.go
│   ├── integration-echo/
│   │   ├── go.mod
│   │   ├── go.sum
│   │   ├── home.templ
│   │   ├── home_templ.go
│   │   └── main.go
│   ├── integration-gin/
│   │   ├── gintemplrenderer/
│   │   │   └── renderer.go
│   │   ├── go.mod
│   │   ├── go.sum
│   │   ├── home.html
│   │   ├── home.templ
│   │   ├── home_templ.go
│   │   └── main.go
│   ├── integration-go-echarts/
│   │   ├── components.templ
│   │   ├── components_templ.go
│   │   ├── go.mod
│   │   ├── go.sum
│   │   └── main.go
│   ├── integration-gofiber/
│   │   ├── README.md
│   │   ├── go.mod
│   │   ├── go.sum
│   │   ├── home.templ
│   │   ├── home_templ.go
│   │   └── main.go
│   ├── integration-react/
│   │   ├── README.md
│   │   ├── components.templ
│   │   ├── components_templ.go
│   │   ├── flake.nix
│   │   ├── go.mod
│   │   ├── go.sum
│   │   ├── main.go
│   │   ├── react/
│   │   │   ├── .gitignore
│   │   │   ├── components.tsx
│   │   │   ├── index.ts
│   │   │   ├── package.json
│   │   │   └── tsconfig.json
│   │   └── static/
│   │       └── index.js
│   ├── internationalization/
│   │   ├── components.templ
│   │   ├── components_templ.go
│   │   ├── go.mod
│   │   ├── go.sum
│   │   ├── locales/
│   │   │   ├── de/
│   │   │   │   └── de.yaml
│   │   │   ├── en/
│   │   │   │   └── en.yaml
│   │   │   ├── locales.go
│   │   │   └── zh-cn/
│   │   │       └── zh-cn.yaml
│   │   └── main.go
│   ├── static-generator/
│   │   ├── .gitignore
│   │   ├── Dockerfile
│   │   ├── blog.templ
│   │   ├── blog_templ.go
│   │   ├── fly.toml
│   │   ├── go.mod
│   │   ├── go.sum
│   │   └── main.go
│   ├── streaming/
│   │   ├── go.mod
│   │   ├── go.sum
│   │   ├── main.templ
│   │   └── main_templ.go
│   ├── suspense/
│   │   ├── go.mod
│   │   ├── go.sum
│   │   ├── main.templ
│   │   └── main_templ.go
│   ├── syntax-and-usage/
│   │   └── components/
│   │       ├── main.go
│   │       ├── templsyntax.templ
│   │       └── templsyntax_templ.go
│   └── typescript/
│       ├── README.md
│       ├── assets/
│       │   └── js/
│       │       └── index.js
│       ├── components/
│       │   ├── index.templ
│       │   └── index_templ.go
│       ├── go.mod
│       ├── go.sum
│       ├── main.go
│       └── ts/
│           ├── package.json
│           └── src/
│               └── index.ts
├── flake.nix
├── flush.go
├── flush_test.go
├── fragment.go
├── fragment_test.go
├── generator/
│   ├── generator.go
│   ├── generator_test.go
│   ├── htmldiff/
│   │   └── diff.go
│   ├── rangewriter.go
│   ├── rangewriter_test.go
│   ├── test-a-href/
│   │   ├── expected.html
│   │   ├── render_test.go
│   │   ├── template.templ
│   │   └── template_templ.go
│   ├── test-attribute-errors/
│   │   ├── expected.html
│   │   ├── render_test.go
│   │   ├── template.templ
│   │   └── template_templ.go
│   ├── test-attribute-escaping/
│   │   ├── expected.html
│   │   ├── render_test.go
│   │   ├── template.templ
│   │   └── template_templ.go
│   ├── test-call/
│   │   ├── expected.html
│   │   ├── render_test.go
│   │   ├── template.templ
│   │   └── template_templ.go
│   ├── test-cancelled-context/
│   │   ├── render_test.go
│   │   ├── template.templ
│   │   └── template_templ.go
│   ├── test-class-whitespace/
│   │   ├── expected.html
│   │   ├── render_test.go
│   │   ├── template.templ
│   │   └── template_templ.go
│   ├── test-complex-attributes/
│   │   ├── expected.html
│   │   ├── render_test.go
│   │   ├── template.templ
│   │   └── template_templ.go
│   ├── test-constant-attribute-escaping/
│   │   ├── expected.html
│   │   ├── render_test.go
│   │   ├── template.templ
│   │   └── template_templ.go
│   ├── test-context/
│   │   ├── expected.html
│   │   ├── render_test.go
│   │   ├── template.templ
│   │   └── template_templ.go
│   ├── test-css-expression/
│   │   ├── constants.go
│   │   ├── render_test.go
│   │   ├── template.templ
│   │   └── template_templ.go
│   ├── test-css-middleware/
│   │   ├── expected.html
│   │   ├── render_test.go
│   │   ├── template.templ
│   │   └── template_templ.go
│   ├── test-css-usage/
│   │   ├── expected.html
│   │   ├── render_test.go
│   │   ├── template.templ
│   │   └── template_templ.go
│   ├── test-doctype/
│   │   ├── expected.html
│   │   ├── render_test.go
│   │   ├── template.templ
│   │   └── template_templ.go
│   ├── test-doctype-html4/
│   │   ├── expected.html
│   │   ├── render_test.go
│   │   ├── template.templ
│   │   └── template_templ.go
│   ├── test-element-attributes/
│   │   ├── data.go
│   │   ├── expected.html
│   │   ├── render_test.go
│   │   ├── template.templ
│   │   └── template_templ.go
│   ├── test-elseif/
│   │   ├── data.go
│   │   ├── expected.html
│   │   ├── render_test.go
│   │   ├── template.templ
│   │   └── template_templ.go
│   ├── test-for/
│   │   ├── expected.html
│   │   ├── render_test.go
│   │   ├── template.templ
│   │   └── template_templ.go
│   ├── test-form-action/
│   │   ├── expected.html
│   │   ├── render_test.go
│   │   ├── template.templ
│   │   └── template_templ.go
│   ├── test-fragment/
│   │   ├── complete.html
│   │   ├── render_test.go
│   │   ├── template.templ
│   │   └── template_templ.go
│   ├── test-go-comments/
│   │   ├── expected.html
│   │   ├── render_test.go
│   │   ├── template.templ
│   │   └── template_templ.go
│   ├── test-go-template-in-templ/
│   │   ├── expected.html
│   │   ├── render_test.go
│   │   ├── template.templ
│   │   └── template_templ.go
│   ├── test-html/
│   │   ├── data.go
│   │   ├── expected.html
│   │   ├── render_test.go
│   │   ├── template.templ
│   │   └── template_templ.go
│   ├── test-html-comment/
│   │   ├── expected.html
│   │   ├── render_test.go
│   │   ├── template.templ
│   │   └── template_templ.go
│   ├── test-if/
│   │   ├── data.go
│   │   ├── expected.html
│   │   ├── render_test.go
│   │   ├── template.templ
│   │   └── template_templ.go
│   ├── test-ifelse/
│   │   ├── data.go
│   │   ├── expected.html
│   │   ├── render_test.go
│   │   ├── template.templ
│   │   └── template_templ.go
│   ├── test-import/
│   │   ├── expected.html
│   │   ├── render_test.go
│   │   ├── template.templ
│   │   └── template_templ.go
│   ├── test-js-unsafe-usage/
│   │   ├── expected.html
│   │   ├── render_test.go
│   │   ├── template.templ
│   │   └── template_templ.go
│   ├── test-js-usage/
│   │   ├── expected.html
│   │   ├── render_test.go
│   │   ├── template.templ
│   │   └── template_templ.go
│   ├── test-method/
│   │   ├── expected.html
│   │   ├── render_test.go
│   │   ├── template.templ
│   │   └── template_templ.go
│   ├── test-once/
│   │   ├── expected.html
│   │   ├── render_test.go
│   │   ├── template.templ
│   │   └── template_templ.go
│   ├── test-only-scripts/
│   │   ├── expected.html
│   │   ├── render_test.go
│   │   ├── template.templ
│   │   └── template_templ.go
│   ├── test-primitives/
│   │   ├── expected.html
│   │   ├── render_test.go
│   │   ├── template.templ
│   │   └── template_templ.go
│   ├── test-raw-elements/
│   │   ├── expected.html
│   │   ├── render_test.go
│   │   ├── template.templ
│   │   └── template_templ.go
│   ├── test-script-expressions/
│   │   ├── expected.html
│   │   ├── render_test.go
│   │   ├── template.templ
│   │   └── template_templ.go
│   ├── test-script-inline/
│   │   ├── expected.html
│   │   ├── render_test.go
│   │   ├── template.templ
│   │   └── template_templ.go
│   ├── test-script-usage/
│   │   ├── expected.html
│   │   ├── render_test.go
│   │   ├── template.templ
│   │   └── template_templ.go
│   ├── test-script-usage-nonce/
│   │   ├── expected.html
│   │   ├── render_test.go
│   │   ├── template.templ
│   │   └── template_templ.go
│   ├── test-spread-attributes/
│   │   ├── expected.html
│   │   ├── expected_numeric_attributes.html
│   │   ├── expected_ordered_attributes.html
│   │   ├── render_test.go
│   │   ├── template.templ
│   │   └── template_templ.go
│   ├── test-string/
│   │   ├── expected.html
│   │   ├── render_test.go
│   │   ├── template.templ
│   │   └── template_templ.go
│   ├── test-string-errors/
│   │   ├── expected.html
│   │   ├── render_test.go
│   │   ├── template.templ
│   │   └── template_templ.go
│   ├── test-style-attribute/
│   │   ├── expected.html
│   │   ├── render_test.go
│   │   ├── template.templ
│   │   └── template_templ.go
│   ├── test-switch/
│   │   ├── render_test.go
│   │   ├── template.templ
│   │   └── template_templ.go
│   ├── test-switchdefault/
│   │   ├── render_test.go
│   │   ├── template.templ
│   │   └── template_templ.go
│   ├── test-templ-element/
│   │   ├── expected.html
│   │   ├── render_test.go
│   │   ├── template.templ
│   │   └── template_templ.go
│   ├── test-templ-in-go-template/
│   │   ├── expected.html
│   │   ├── render_test.go
│   │   ├── template.templ
│   │   └── template_templ.go
│   ├── test-text/
│   │   ├── expected.html
│   │   ├── render_test.go
│   │   ├── template.templ
│   │   └── template_templ.go
│   ├── test-text-whitespace/
│   │   ├── render_test.go
│   │   ├── template.templ
│   │   └── template_templ.go
│   ├── test-void/
│   │   ├── expected.html
│   │   ├── render_test.go
│   │   ├── template.templ
│   │   └── template_templ.go
│   └── test-whitespace-around-go-keywords/
│       ├── render_test.go
│       ├── template.templ
│       └── template_templ.go
├── go.mod
├── go.sum
├── handler.go
├── handler_test.go
├── internal/
│   ├── format/
│   │   ├── format_test.go
│   │   ├── scriptelement.go
│   │   ├── styleelement.go
│   │   ├── templ.go
│   │   └── testdata/
│   │       ├── all_children_indented__with_nested_indentation__when_close_tag_is_on_new_line.txt
│   │       ├── all_children_indented__with_nested_indentation__when_close_tag_is_on_same_line.txt
│   │       ├── br_and_hr_all_on_one_line_are_not_placed_on_new_lines.txt
│   │       ├── br_elements_are_placed_on_new_lines.txt
│   │       ├── children_indented__closing_elm.txt
│   │       ├── children_indented__first_child.txt
│   │       ├── comments_are_preserved.txt
│   │       ├── conditional_expressions_have_the_same_child_indentation_rules_as_regular_elements.txt
│   │       ├── conditional_expressions_result_in_all_attrs_indented.txt
│   │       ├── conditional_expressions_result_in_all_attrs_indented__2.txt
│   │       ├── conditional_expressions_with_else_blocks_are_also_formatted.txt
│   │       ├── constant_attributes_prerfer_double_quotes__but_use_single_quotes_if_required.txt
│   │       ├── css_is_indented_by_one_level.txt
│   │       ├── css_whitespace_is_tidied.txt
│   │       ├── cssarguments_multiline.txt
│   │       ├── empty_elements_stay_on_the_same_line.txt
│   │       ├── for_loops_are_placed_on_a_new_line.txt
│   │       ├── formatting_does_not_alter_whitespace.txt
│   │       ├── go_expressions_are_formatted_by_the_go_formatter.txt
│   │       ├── go_expressions_have_whitespace_normalised.txt
│   │       ├── godoc_comments_are_preserved.txt
│   │       ├── if_statements_are_placed_on_a_new_line.txt
│   │       ├── inline_elements_are_not_placed_on_a_new_line.txt
│   │       ├── inline_func_blank_lines_no_whitespace.txt
│   │       ├── multiline_string_literal_indentation_preserved.txt
│   │       ├── non_empty_elements_with_children_that_are_all_on_the_same_line_are_not_split_into_multiple_lines.txt
│   │       ├── raw_go_is_formatted.txt
│   │       ├── script_tags_are_not_converted_to_self_closing_elements.txt
│   │       ├── scriptarguments_multiline.txt
│   │       ├── scriptelement_contents_are_formatted.txt
│   │       ├── scriptelements_hyperscript_is_ignored.txt
│   │       ├── scriptelements_with_go_code_are_formatted.txt
│   │       ├── scriptelements_with_multiple_go_code_sections_are_formatted.txt
│   │       ├── scriptelements_within_templ_expressions_are_formatted.txt
│   │       ├── spacing_between_string_expressions_is_kept.txt
│   │       ├── spacing_between_string_expressions_is_not_magically_added.txt
│   │       ├── spacing_between_string_spreads_attributes_is_kept.txt
│   │       ├── styleelements_are_formatted.txt
│   │       ├── switch_statements_are_placed_on_a_new_line.txt
│   │       ├── tables_are_formatted_well.txt
│   │       ├── templ_expression_attributes_are_formatted_correctly_when_multiline.txt
│   │       ├── templ_expression_elements_are_formatted_the_same_as_other_elements.txt
│   │       ├── templatearguments_multiline_with_generics.txt
│   │       ├── templatefile_can_be_round_tripped.txt
│   │       ├── templatefile_can_start_with_comments.txt
│   │       ├── templatefile_can_start_with_comments_and_whitespace.txt
│   │       ├── templatefile_can_start_with_multiline_comments_and_whitespace.txt
│   │       ├── templatefile_can_start_with_multiple_comments_and_whitespace.txt
│   │       ├── templateheader_with_build_tags.txt
│   │       ├── templelement_multiline_block_containing_multiline_block.txt
│   │       ├── templelement_multiline_block_indentation.txt
│   │       ├── templelement_multiline_in_div.txt
│   │       ├── templelement_param_spacing.txt
│   │       ├── templelement_simple_block_indentation.txt
│   │       ├── templelement_simple_in_div.txt
│   │       ├── templelement_simple_no_change.txt
│   │       ├── void_elements_are_converted_to_self_closing_elements.txt
│   │       └── when_an_element_contains_children_that_are_on_new_lines__the_children_are_indented.txt
│   ├── htmlfind/
│   │   ├── htmlfind.go
│   │   └── htmlfind_test.go
│   ├── imports/
│   │   ├── process.go
│   │   ├── process_test.go
│   │   └── testdata/
│   │       ├── comments.txtar
│   │       ├── commentsbeforepackage.txtar
│   │       ├── deleteimports.txtar
│   │       ├── extraspace.txtar
│   │       ├── groups.txtar
│   │       ├── groupsmanynewlines.txtar
│   │       ├── header.txtar
│   │       ├── hyphenatedimport.txtar
│   │       ├── namedimportsadd.txtar
│   │       ├── namedimportsremoved.txtar
│   │       ├── noimports.txtar
│   │       ├── noimportscode.txtar
│   │       ├── stringexp.txtar
│   │       └── twoimports.txtar
│   ├── lazyloader/
│   │   ├── docheader.go
│   │   ├── docheader_test.go
│   │   ├── docheaderparser.go
│   │   ├── docheaderparser_test.go
│   │   ├── pkgloader.go
│   │   ├── pkgloader_test.go
│   │   ├── pkgtraverser.go
│   │   ├── pkgtraverser_test.go
│   │   ├── templdoclazyloader.go
│   │   └── templdoclazyloader_test.go
│   ├── prettier/
│   │   ├── prettier.go
│   │   ├── prettier_test.go
│   │   └── testdata.txtar
│   ├── skipdir/
│   │   ├── skipdir.go
│   │   └── skipdir_test.go
│   ├── syncmap/
│   │   ├── map.go
│   │   └── map_test.go
│   └── syncset/
│       ├── set.go
│       └── set_test.go
├── join.go
├── join_test.go
├── js.go
├── js_test.go
├── jsonscript.go
├── jsonscript_test.go
├── jsonstring.go
├── jsonstring_test.go
├── lsp/
│   ├── LICENSE
│   ├── README.md
│   ├── jsonrpc2/
│   │   ├── codes.go
│   │   ├── conn.go
│   │   ├── errors.go
│   │   ├── handler.go
│   │   ├── jsonrpc2.go
│   │   ├── jsonrpc2_test.go
│   │   ├── message.go
│   │   ├── serve.go
│   │   ├── serve_test.go
│   │   ├── stream.go
│   │   ├── wire.go
│   │   └── wire_test.go
│   ├── protocol/
│   │   ├── base.go
│   │   ├── base_test.go
│   │   ├── basic.go
│   │   ├── basic_test.go
│   │   ├── callhierarchy.go
│   │   ├── callhierarchy_test.go
│   │   ├── capabilities_client.go
│   │   ├── capabilities_client_test.go
│   │   ├── capabilities_server.go
│   │   ├── client.go
│   │   ├── context.go
│   │   ├── deprecated.go
│   │   ├── diagnostics.go
│   │   ├── diagnostics_test.go
│   │   ├── doc.go
│   │   ├── errors.go
│   │   ├── general.go
│   │   ├── general_test.go
│   │   ├── handler.go
│   │   ├── language.go
│   │   ├── language_test.go
│   │   ├── progress.go
│   │   ├── progress_test.go
│   │   ├── protocol.go
│   │   ├── registration.go
│   │   ├── registration_test.go
│   │   ├── selectionrange.go
│   │   ├── semantic_token.go
│   │   ├── server.go
│   │   ├── text.go
│   │   ├── text_test.go
│   │   ├── util.go
│   │   ├── util_test.go
│   │   ├── version.go
│   │   ├── window.go
│   │   ├── window_test.go
│   │   ├── workspace.go
│   │   └── workspace_test.go
│   ├── uri/
│   │   ├── uri.go
│   │   └── uri_test.go
│   └── xcontext/
│       └── xcontext.go
├── once.go
├── once_test.go
├── parser/
│   └── v2/
│       ├── allocs_test.go
│       ├── benchmarks_test.go
│       ├── benchmarktestdata/
│       │   └── benchmark.txt
│       ├── calltemplateparser.go
│       ├── calltemplateparser_test.go
│       ├── childrenparser.go
│       ├── childrenparser_test.go
│       ├── conditionalattributeparser.go
│       ├── cssparser.go
│       ├── cssparser_test.go
│       ├── diagnostics.go
│       ├── diagnostics_test.go
│       ├── doctypeparser.go
│       ├── doctypeparser_test.go
│       ├── elementparser.go
│       ├── elementparser_test.go
│       ├── expressionparser.go
│       ├── expressionparser_test.go
│       ├── fallthroughparser.go
│       ├── fallthroughparser_test.go
│       ├── forexpressionparser.go
│       ├── forexpressionparser_test.go
│       ├── fuzz.sh
│       ├── gocodeparser.go
│       ├── gocodeparser_test.go
│       ├── gocommentparser.go
│       ├── gocommentparser_test.go
│       ├── goexpression/
│       │   ├── fuzz.sh
│       │   ├── parse.go
│       │   ├── parse_test.go
│       │   ├── parsebench_test.go
│       │   ├── scanner.go
│       │   └── testdata/
│       │       └── fuzz/
│       │           ├── FuzzCaseDefault/
│       │           │   ├── 3c6f43d3ec8a900b
│       │           │   ├── 986e7bc325c7890c
│       │           │   └── d8a9a4cd9fc8cb11
│       │           ├── FuzzExpression/
│       │           │   └── ac5d99902f5e7914
│       │           ├── FuzzFuncs/
│       │           │   └── 46c9ed6c9d427bd2
│       │           └── FuzzIf/
│       │               └── 7a174efc13e3fdd6
│       ├── goparser.go
│       ├── htmlcommentparser.go
│       ├── htmlcommentparser_test.go
│       ├── ifexpressionparser.go
│       ├── ifexpressionparser_test.go
│       ├── packageparser.go
│       ├── packageparser_test.go
│       ├── parser.go
│       ├── raw.go
│       ├── raw_test.go
│       ├── scriptparser.go
│       ├── scriptparser_test.go
│       ├── scriptparsertestdata/
│       │   ├── backtickquote.txt
│       │   ├── backtickquote_apostrophe.txt
│       │   ├── doublequote.txt
│       │   ├── doublequote_apostrophe.txt
│       │   ├── escapechars.txt
│       │   ├── non_js_script.txt
│       │   ├── regexp_literal.txt
│       │   ├── showsuccessmessage.txt
│       │   ├── singlequote.txt
│       │   ├── singlequote_apostrophe.txt
│       │   └── terminating_comment.txt
│       ├── scripttemplateparser.go
│       ├── scripttemplateparser_test.go
│       ├── sourcemap.go
│       ├── sourcemap_test.go
│       ├── stringexpressionparser.go
│       ├── stringexpressionparser_test.go
│       ├── structure.go
│       ├── switchexpressionparser.go
│       ├── switchexpressionparser_test.go
│       ├── templatefile.go
│       ├── templatefile_test.go
│       ├── templateparser.go
│       ├── templateparser_test.go
│       ├── templelementparser.go
│       ├── templelementparser_test.go
│       ├── testdata/
│       │   └── fuzz/
│       │       └── FuzzScriptParser/
│       │           ├── 0667fe9c719c304f
│       │           ├── 21c86d8a2781524b
│       │           └── 43cd47dd50874af5
│       ├── textparser.go
│       ├── textparser_test.go
│       ├── types.go
│       ├── visitor/
│       │   ├── visitor.go
│       │   └── visitor_test.go
│       ├── visitor.go
│       └── whitespaceparser.go
├── runtime/
│   ├── buffer.go
│   ├── buffer_test.go
│   ├── bufferpool.go
│   ├── bufferpool_test.go
│   ├── builder.go
│   ├── builder_test.go
│   ├── fuzzing/
│   │   ├── fuzz.templ
│   │   ├── fuzz_templ.go
│   │   ├── fuzz_test.go
│   │   ├── go.mod
│   │   ├── go.sum
│   │   └── testdata/
│   │       └── fuzz/
│   │           ├── FuzzComponentAny/
│   │           │   ├── 02bc261247f1267d
│   │           │   ├── 0e3d2540388fc8bd
│   │           │   ├── 0ed510998a1c1a4e
│   │           │   └── 926b62a033ecc0fd
│   │           └── FuzzComponentString/
│   │               ├── 4a59bdc98ee75491
│   │               ├── 66658924a0ea89b6
│   │               └── 9fc8b4df9a42170c
│   ├── runtime.go
│   ├── runtime_test.go
│   ├── scriptelement.go
│   ├── scriptelement_test.go
│   ├── styleattribute.go
│   ├── styleattribute_test.go
│   ├── watchmode.go
│   └── watchmode_test.go
├── runtime.go
├── runtime_test.go
├── safehtml/
│   ├── style.go
│   └── style_test.go
├── scripttemplate.go
├── scripttemplate_test.go
├── storybook/
│   ├── .gitignore
│   ├── _example/
│   │   ├── cdk/
│   │   │   ├── .gitignore
│   │   │   ├── README.md
│   │   │   ├── cdk.go
│   │   │   ├── cdk.json
│   │   │   └── deploy.sh
│   │   ├── go.mod
│   │   ├── go.sum
│   │   ├── lambda/
│   │   │   └── main.go
│   │   ├── local/
│   │   │   └── main.go
│   │   ├── run.sh
│   │   ├── storybook.go
│   │   ├── templates.templ
│   │   └── templates_templ.go
│   ├── _package.json
│   └── storybook.go
├── turbo/
│   ├── stream.go
│   ├── stream.templ
│   ├── stream_templ.go
│   └── stream_test.go
├── url.go
├── url_test.go
├── version.go
└── watchmode.go

================================================
FILE CONTENTS
================================================

================================================
FILE: .dockerignore
================================================
.git
Dockerfile
.dockerignore


================================================
FILE: .envrc
================================================
use flake

================================================
FILE: .github/FUNDING.yml
================================================
github: [a-h, joerdav]


================================================
FILE: .github/ISSUE_TEMPLATE/bug_report.md
================================================
---
name: Bug report
about: Create a report to help us improve
title: ''
labels: ''
assignees: ''

---

**Before you begin**
Please make sure you're using the latest version of the templ CLI (`go install github.com/a-h/templ/cmd/templ@latest`), and have upgraded your project to use the latest version of the templ runtime (`go get -u github.com/a-h/templ@latest`)

**Describe the bug**
A clear and concise description of what the bug is.

**To Reproduce**
A small, self-contained, complete reproduction, uploaded to a GitHub repo, containing the minimum amount of files required to reproduce the behaviour, along with a list of commands that need to be run. Keep it simple.

**Expected behavior**
A clear and concise description of what you expected to happen.

**Screenshots**
If applicable, add screenshots or screen captures to help explain your problem.

**Logs**
If the issue is related to IDE support, run through the LSP troubleshooting section at https://templ.guide/developer-tools/ide-support/#troubleshooting-1 and include logs from templ

**`templ info` output**
Run `templ info` and include the output.

**Desktop (please complete the following information):**
 - OS: [e.g. MacOS, Linux, Windows, WSL]
 - templ CLI version (`templ version`)
- Go version (`go version`)
- `gopls` version (`gopls version`)

**Additional context**
Add any other context about the problem here.


================================================
FILE: .github/copilot-instructions.md
================================================
# Coding standards

## Behaviour

* Always run `go fmt` after making changes to Go code.
* Always run unit tests after making changes to Go code.

## Environment setup

* Ensure that the user has direnv installed, and that it is set up correctly in their shell. See https://direnv.net/docs/installation.html
* Ensure that the user has Nix installed, and that it is set up correctly. See https://nixos.org/download.html
* Ensure that the user has the direnv VS code extension installed, so that the `.envrc` file is automatically loaded when the project is opened in VS Code.

### Background

templ has an `.envrc` file that is used to set up the development environment using a tool called `direnv`. There is a VS Code extension available that will automatically load this when you open the project in VS Code.

The `.envrc` file uses a Nix flake to set up the environment, so Nix is required to be installed.

The version of Go used is defined in the `flake.nix` file.

## Build tasks

templ uses the `xc` task runner - https://github.com/joerdav/xc

If you run `xc` you can get see a list of the development tasks that can be run, or you can read the `README.md` file and see the `Tasks` section.

The most useful tasks for local development are:

* `xc install-snapshot` - builds the templ CLI and installs it into `~/bin`. Ensure that this is in your path.
* `xc generate` - generates Go code from the templ files in the project.
* `xc test` - regenerates all templates, and runs the unit tests.
* `xc test-short` - runs shorter tests, avoiding long running tests for filesystem watchers etc.
* `xc fmt` - runs `gofmt` to format all Go code.
* `xc lint` - run the same linting as run in the CI process.
* `xc docs-run` - run the Docusaurus documentation site.

templ has a code generation step, this is automatically carried out using `xc test`.

Don't install templ globally using `xc install-snapshot` or `go install`. Use the `xc generate` or `xc test-short` tasks to generate the code, which will also run the tests.

## Commit messages

The project using https://www.conventionalcommits.org/en/v1.0.0/

Examples:

* `feat: support Go comments in templates, fixes #234"`
* `fix: ensure that the templ CLI works with Go 1.21, fixes #123`

## Documentation

* Documentation is written in Markdown, and is rendered using Docusaurus. The documentation is in the `docs` directory.
* Update documentation when the behaviour of templ changes, or when new features are added.

## Writing style

* Use American English spelling to match the Go standard library, and HTML spec, e.g. "color".
* Use the Oxford comma, e.g. "apples, oranges, and bananas".
* Avoid use of emojis everywhere - in code, comments, commit messages, and documentation.
* Be "to the point" and precise - avoid unnecessary words, don't use filler words like "just" or "really".
* Use the active voice, e.g. "templ generates code" rather than "code is generated by templ".
* Don't use emphatic words or phrases like "very", "blazingly fast", etc.

## Coding style

* Reduce nesting - i.e. prefer early returns over an `else` block, as per https://danp.net/posts/reducing-go-nesting/ or https://go.dev/doc/effective_go#if
* Use line breaks to separate "paragraphs" of code - don't use line breaks in between lines, or at the start/end of functions etc.
* Use the `xc fmt` and `xc lint` build tasks to format and lint code before committing.
* Don't use unnecessary comments that explain what the code does.
* If comments are used, ensure that they are full sentences, and use proper punctuation, including ending with a full stop.
* Don't write comments after the end of keywords, e.g. `continue // Only process pairs`

## Tests

* Tests for generated code are in the `./generator` directory. Each test is in a subdirectory.
* Tests for the templ CLI are in the `./cmd/templ` directory.
* Tests for the templ runtime are in the root directory.
* Tests for formatting templ files are in `./parser/v2/formattestdata` - it uses txtar to store tests.
* The `htmldiff` library does not take whitespace into account, so cannot be used to test output whitespace handling.
* Don't attempt to run tests individually, use the `xc test` task to run all tests, because it regenerates templates, and there's minimal performance penalty due to Go's test caching.

## Moving and renaming files

* templ files have the `.templ` extension.
* If a `project.templ` file is created, after generation a `project_templ.go` file will be created.
* If a `project.templ` file is renamed, you must also rename the generated `project_templ.go` file.
* If a `project.templ` file is moved, you must also move the generated `project_templ.go` file.
* If a `project.templ` file is deleted, you must also delete the generated `project_templ.go` file.

# Files

* Don't attempt to create helper or utility tests in the `./tmp` or `/tmp` directory. Create unit tests in the relevant directory instead.

================================================
FILE: .github/workflows/ci.yml
================================================
name: CI

on:
  push:
    branches: [main]
  pull_request:
    branches: [main]

permissions:
  contents: read

jobs:
  build:
    runs-on: ubuntu-latest
    steps:
      - uses: actions/checkout@v4

      - uses: nixbuild/nix-quick-install-action@v30
        with:
          github_access_token: ${{ secrets.GITHUB_TOKEN }}

      - name: Restore and save Nix store
        uses: nix-community/cache-nix-action@v6
        with:
          primary-key: nix-${{ runner.os }}-${{ hashFiles('**/*.nix', '**/flake.lock') }}
          gc-max-store-size-linux: 1G
          purge: true
          purge-prefixes: nix-${{ runner.os }}-
          purge-primary-key: never

      - name: Test
        run: nix develop --command xc test-cover

      - name: Upload coverage artifact
        if: github.event_name == 'push'
        uses: actions/upload-artifact@v4
        with:
          name: coverage
          path: coverage.out
      
      - name: Build
        run: nix build

  update-coverage:
    if: github.event_name == 'push'
    needs: build
    runs-on: ubuntu-latest
    permissions:
      contents: write
    steps:
      - uses: actions/checkout@v4

      - name: Download coverage
        uses: actions/download-artifact@v4
        with:
          name: coverage

      - name: Update coverage report
        uses: ncruces/go-coverage-report@57ac6f0f19874f7afbab596105154f08004f482e
        with:
          coverage-file: coverage.out
          report: 'true'
          chart: 'true'
          reuse-go: 'true'

  lint:
    runs-on: ubuntu-latest
    steps:
      - uses: actions/checkout@v4

      - uses: nixbuild/nix-quick-install-action@v30
        with:
          github_access_token: ${{ secrets.GITHUB_TOKEN }}

      - name: Restore and save Nix store
        uses: nix-community/cache-nix-action@v6
        with:
          primary-key: nix-${{ runner.os }}-${{ hashFiles('**/*.nix', '**/flake.lock') }}
          gc-max-store-size-linux: 1G
          purge: true
          purge-prefixes: nix-${{ runner.os }}-
          purge-primary-key: never

      - name: Lint
        run: nix develop --command xc lint

  ensure-generated:
    runs-on: ubuntu-latest
    steps:
      - uses: actions/checkout@v4

      - uses: nixbuild/nix-quick-install-action@v30
        with:
          github_access_token: ${{ secrets.GITHUB_TOKEN }}

      - name: Restore and save Nix store
        uses: nix-community/cache-nix-action@v6
        with:
          primary-key: nix-${{ runner.os }}-${{ hashFiles('**/*.nix', '**/flake.lock') }}
          gc-max-store-size-linux: 1G
          purge: true
          purge-prefixes: nix-${{ runner.os }}-
          purge-primary-key: never

      - name: Generate
        run: nix develop --command xc ensure-generated

  ensure-fmt:
    runs-on: ubuntu-latest
    steps:
      - uses: actions/checkout@v4

      - uses: nixbuild/nix-quick-install-action@v30
        with:
          github_access_token: ${{ secrets.GITHUB_TOKEN }}

      - name: Restore and save Nix store
        uses: nix-community/cache-nix-action@v6
        with:
          primary-key: nix-${{ runner.os }}-${{ hashFiles('**/*.nix', '**/flake.lock') }}
          gc-max-store-size-linux: 1G
          purge: true
          purge-prefixes: nix-${{ runner.os }}-
          purge-primary-key: never

      - name: Fmt
        run: nix develop --command xc fmt

      - name: Ensure clean
        run: git diff --exit-code


================================================
FILE: .github/workflows/docs.yaml
================================================
name: Deploy Docs

on:
  release:
    types: [published]
  workflow_dispatch:

permissions:
  contents: read
  pages: write
  id-token: write

concurrency:
  group: "pages"
  cancel-in-progress: false

defaults:
  run:
    shell: bash

jobs:
  build-docs:
    runs-on: ubuntu-latest
    steps:
      - name: Checkout
        uses: actions/checkout@v4
        with:
          submodules: recursive
          fetch-depth: 0
      - name: Setup Pages
        id: pages
        uses: actions/configure-pages@v5
      - uses: actions/setup-node@v4
        with:
          node-version: '20'
          cache: npm
          cache-dependency-path: "./docs/package-lock.json"
      - name: Install Node.js dependencies
        run: |
          cd docs
          npm ci
      - name: Build
        run: |
          cd docs
          npm run build
      - name: Upload artifact
        uses: actions/upload-pages-artifact@v3
        with:
          path: ./docs/build

  deploy-docs:
    environment:
      name: github-pages
      url: ${{ steps.deployment.outputs.page_url }}
    runs-on: ubuntu-latest
    needs: build-docs
    steps:
      - name: Deploy to GitHub Pages
        id: deployment
        uses: actions/deploy-pages@v4


================================================
FILE: .github/workflows/flakehub-publish-tagged.yml
================================================
name: "Publish tags to FlakeHub"
on:
  push:
    tags:
      - "v?[0-9]+.[0-9]+.[0-9]+*"
  workflow_dispatch:
    inputs:
      tag:
        description: "The existing tag to publish to FlakeHub"
        type: "string"
        required: true
jobs:
  flakehub-publish:
    runs-on: "ubuntu-latest"
    permissions:
      id-token: "write"
      contents: "read"
    steps:
      - uses: "actions/checkout@v4"
        with:
          ref: "${{ (inputs.tag != null) && format('refs/tags/{0}', inputs.tag) || '' }}"
      - uses: "DeterminateSystems/determinate-nix-action@v3"
      - uses: "DeterminateSystems/flakehub-push@main"
        with:
          visibility: "public"
          name: "a-h/templ"
          tag: "${{ inputs.tag }}"
          include-output-paths: true


================================================
FILE: .github/workflows/release.yml
================================================
name: Release

on:
  push:
    tags:
      - 'v*'
  workflow_dispatch:

permissions:
   contents: write
   packages: write

jobs:
  release:
    runs-on: ubuntu-latest
    steps:
      - uses: actions/checkout@v4
        with:
          fetch-depth: 0
      - uses: actions/setup-go@v5
        with:
          go-version: 1.23
          cache: true
      - uses: ko-build/setup-ko@v0.7
      - uses: sigstore/cosign-installer@v3.7.0
        with:
          cosign-release: v2.2.3
      - uses: goreleaser/goreleaser-action@v5
        with:
          version: v1.24.0
          args: release --clean
        env:
          GITHUB_TOKEN: '${{ secrets.GITHUB_TOKEN }}'
          COSIGN_PASSWORD: '${{ secrets.COSIGN_PASSWORD }}'
          COSIGN_PRIVATE_KEY: '${{ secrets.COSIGN_PRIVATE_KEY }}'
          COSIGN_PUBLIC_KEY: '${{ secrets.COSIGN_PUBLIC_KEY }}'


================================================
FILE: .gitignore
================================================
# Output.
cmd/templ/templ

# Logs.
cmd/templ/lspcmd/*log.txt

# Go code coverage.
coverage.out
coverage

# Mac filesystem jank.
.DS_Store

# Docusaurus.
docs/build/
docs/resources/_gen/
node_modules/
dist/

# Nix artifacts.
result

# Editors
## nvim
.null-ls*
# vscode
.vscode/

# Go workspace.
go.work

# direnv
.direnv

# templ txt files.
*_templ.txt

# Example output binaries.
/examples/integration-gin/integration-gin
/examples/integration-echo/integration-echo


================================================
FILE: .goreleaser.yaml
================================================
builds:
  - env:
      - CGO_ENABLED=0
    dir: cmd/templ
    mod_timestamp: '{{ .CommitTimestamp }}'
    flags:
      - -trimpath
    ldflags:
      - -s -w
    goos:
      - linux
      - windows
      - darwin

checksum:
  name_template: 'checksums.txt'

signs:
  - id: checksums
    cmd: cosign
    stdin: '{{ .Env.COSIGN_PASSWORD }}'
    output: true
    artifacts: checksum
    args:
      - sign-blob
      - --yes
      - --key
      - env://COSIGN_PRIVATE_KEY
      - '--output-certificate=${certificate}'
      - '--output-signature=${signature}'
      - '${artifact}'

archives:
  - format: tar.gz
    name_template: >-
      {{ .ProjectName }}_
      {{- title .Os }}_
      {{- if eq .Arch "amd64" }}x86_64
      {{- else if eq .Arch "386" }}i386
      {{- else }}{{ .Arch }}{{ end }}
      {{- if .Arm }}v{{ .Arm }}{{ end }}

kos:
  - repository: ghcr.io/a-h/templ
    platforms:
    - linux/amd64
    - linux/arm64
    tags:
    - latest
    - '{{.Tag}}'
    bare: true

docker_signs:
  - cmd: cosign
    artifacts: all
    output: true
    args:
      - sign
      - --yes
      - --key
      - env://COSIGN_PRIVATE_KEY
      - '${artifact}'

snapshot:
  name_template: "{{ incpatch .Version }}-next"

changelog:
  sort: asc
  filters:
    exclude:
      - '^docs:'
      - '^test:'


================================================
FILE: .ignore
================================================
*_templ.go
examples/integration-ct/static/index.js
examples/counter/assets/css/bulma.*
examples/counter/assets/js/htmx.min.js
examples/counter-basic/assets/css/bulma.*
examples/typescript/assets/index.js
package-lock.json
go.sum
docs/static/llms.md


================================================
FILE: .version
================================================
0.3.1002

================================================
FILE: CODE_OF_CONDUCT.md
================================================
# Contributor Covenant Code of Conduct

## Our Pledge

We as members, contributors, and leaders pledge to make participation in our
community a harassment-free experience for everyone, regardless of age, body
size, visible or invisible disability, ethnicity, sex characteristics, gender
identity and expression, level of experience, education, socio-economic status,
nationality, personal appearance, race, religion, or sexual identity
and orientation.

We pledge to act and interact in ways that contribute to an open, welcoming,
diverse, inclusive, and healthy community.

## Our Standards

Examples of behavior that contributes to a positive environment for our
community include:

* Demonstrating empathy and kindness toward other people
* Being respectful of differing opinions, viewpoints, and experiences
* Giving and gracefully accepting constructive feedback
* Accepting responsibility and apologizing to those affected by our mistakes,
  and learning from the experience
* Focusing on what is best not just for us as individuals, but for the
  overall community

Examples of unacceptable behavior include:

* The use of sexualized language or imagery, and sexual attention or
  advances of any kind
* Trolling, insulting or derogatory comments, and personal or political attacks
* Public or private harassment
* Publishing others' private information, such as a physical or email
  address, without their explicit permission
* Other conduct which could reasonably be considered inappropriate in a
  professional setting

## Enforcement Responsibilities

Community leaders are responsible for clarifying and enforcing our standards of
acceptable behavior and will take appropriate and fair corrective action in
response to any behavior that they deem inappropriate, threatening, offensive,
or harmful.

Community leaders have the right and responsibility to remove, edit, or reject
comments, commits, code, wiki edits, issues, and other contributions that are
not aligned to this Code of Conduct, and will communicate reasons for moderation
decisions when appropriate.

## Scope

This Code of Conduct applies within all community spaces, and also applies when
an individual is officially representing the community in public spaces.
Examples of representing our community include using an official e-mail address,
posting via an official social media account, or acting as an appointed
representative at an online or offline event.

## Enforcement

Instances of abusive, harassing, or otherwise unacceptable behavior may be
reported to the community leaders responsible for enforcement at
adrianhesketh@hushail.com.
All complaints will be reviewed and investigated promptly and fairly.

All community leaders are obligated to respect the privacy and security of the
reporter of any incident.

## Enforcement Guidelines

Community leaders will follow these Community Impact Guidelines in determining
the consequences for any action they deem in violation of this Code of Conduct:

### 1. Correction

**Community Impact**: Use of inappropriate language or other behavior deemed
unprofessional or unwelcome in the community.

**Consequence**: A private, written warning from community leaders, providing
clarity around the nature of the violation and an explanation of why the
behavior was inappropriate. A public apology may be requested.

### 2. Warning

**Community Impact**: A violation through a single incident or series
of actions.

**Consequence**: A warning with consequences for continued behavior. No
interaction with the people involved, including unsolicited interaction with
those enforcing the Code of Conduct, for a specified period of time. This
includes avoiding interactions in community spaces as well as external channels
like social media. Violating these terms may lead to a temporary or
permanent ban.

### 3. Temporary Ban

**Community Impact**: A serious violation of community standards, including
sustained inappropriate behavior.

**Consequence**: A temporary ban from any sort of interaction or public
communication with the community for a specified period of time. No public or
private interaction with the people involved, including unsolicited interaction
with those enforcing the Code of Conduct, is allowed during this period.
Violating these terms may lead to a permanent ban.

### 4. Permanent Ban

**Community Impact**: Demonstrating a pattern of violation of community
standards, including sustained inappropriate behavior,  harassment of an
individual, or aggression toward or disparagement of classes of individuals.

**Consequence**: A permanent ban from any sort of public interaction within
the community.

## Attribution

This Code of Conduct is adapted from the [Contributor Covenant][homepage],
version 2.0, available at
https://www.contributor-covenant.org/version/2/0/code_of_conduct.html.

Community Impact Guidelines were inspired by [Mozilla's code of conduct
enforcement ladder](https://github.com/mozilla/diversity).

[homepage]: https://www.contributor-covenant.org

For answers to common questions about this code of conduct, see the FAQ at
https://www.contributor-covenant.org/faq. Translations are available at
https://www.contributor-covenant.org/translations.


================================================
FILE: CONTRIBUTING.md
================================================
# Contributing to templ

## Vision

Enable Go developers to build strongly typed, component-based HTML user interfaces with first-class developer tooling, and a short learning curve.

## Come up with a design and share it

Before starting work on any major pull requests or code changes, start a discussion at https://github.com/a-h/templ/discussions or raise an issue.

We don't want you to spend time on a PR or feature that ultimately doesn't get merged because it doesn't fit with the project goals, or the design doesn't work for some reason.

For issues, it really helps if you provide a reproduction repo, or can create a failing unit test to describe the behaviour.

In designs, we need to consider:

* Backwards compatibility - Not changing the public API between releases, introducing gradual deprecation - don't break people's code.
* Correctness over time - How can we reduce the risk of defects both now, and in future releases?
* Threat model - How could each change be used to inject vulnerabilities into web pages?
* Go version - We target the oldest supported version of Go as per https://go.dev/doc/devel/release
* Automatic migration - If we need to force through a change.
* Compile time vs runtime errors - Prefer compile time.
* Documentation - New features are only useful if people can understand the new feature, what would the documentation look like?
* Examples - How will we demonstrate the feature?

## Project structure

templ is structured into a few areas:

### Parser `./parser`

The parser directory currently contains both v1 and v2 parsers.

The v1 parser is not maintained, it's only used to migrate v1 code over to the v2 syntax.

The parser is responsible for parsing templ files into an object model. The types that make up the object model are in `types.go`. Automatic formatting of the types is tested in `types_test.go`.

A templ file is parsed into the `TemplateFile` struct object model.

```go
type TemplateFile struct {
	// Header contains comments or whitespace at the top of the file.
	Header []GoExpression
	// Package expression.
	Package Package
	// Nodes in the file.
	Nodes []TemplateFileNode
}
```

Parsers are individually tested using two types of unit test.

One test covers the successful parsing of text into an object. For example, the `HTMLCommentParser` test checks for successful patterns.

```go
func TestHTMLCommentParser(t *testing.T) {
	var tests = []struct {
		name     string
		input    string
		expected HTMLComment
	}{
		{
			name:  "comment - single line",
			input: `<!-- single line comment -->`,
			expected: HTMLComment{
				Contents: " single line comment ",
			},
		},
		{
			name:  "comment - no whitespace",
			input: `<!--no whitespace between sequence open and close-->`,
			expected: HTMLComment{
				Contents: "no whitespace between sequence open and close",
			},
		},
		{
			name: "comment - multiline",
			input: `<!-- multiline
								comment
					-->`,
			expected: HTMLComment{
				Contents: ` multiline
								comment
					`,
			},
		},
		{
			name:  "comment - with tag",
			input: `<!-- <p class="test">tag</p> -->`,
			expected: HTMLComment{
				Contents: ` <p class="test">tag</p> `,
			},
		},
		{
			name:  "comments can contain tags",
			input: `<!-- <div> hello world </div> -->`,
			expected: HTMLComment{
				Contents: ` <div> hello world </div> `,
			},
		},
	}
	for _, tt := range tests {
		tt := tt
		t.Run(tt.name, func(t *testing.T) {
			input := parse.NewInput(tt.input)
			result, ok, err := htmlComment.Parse(input)
			if err != nil {
				t.Fatalf("parser error: %v", err)
			}
			if !ok {
				t.Fatalf("failed to parse at %d", input.Index())
			}
			if diff := cmp.Diff(tt.expected, result); diff != "" {
				t.Errorf(diff)
			}
		})
	}
}
```

Alongside each success test, is a similar test to check that invalid syntax is detected.

```go
func TestHTMLCommentParserErrors(t *testing.T) {
	var tests = []struct {
		name     string
		input    string
		expected error
	}{
		{
			name:  "unclosed HTML comment",
			input: `<!-- unclosed HTML comment`,
			expected: parse.Error("expected end comment literal '-->' not found",
				parse.Position{
					Index: 26,
					Line:  0,
					Col:   26,
				}),
		},
		{
			name:  "comment in comment",
			input: `<!-- <-- other --> -->`,
			expected: parse.Error("comment contains invalid sequence '--'", parse.Position{
				Index: 8,
				Line:  0,
				Col:   8,
			}),
		},
	}
	for _, tt := range tests {
		tt := tt
		t.Run(tt.name, func(t *testing.T) {
			input := parse.NewInput(tt.input)
			_, _, err := htmlComment.Parse(input)
			if diff := cmp.Diff(tt.expected, err); diff != "" {
				t.Error(diff)
			}
		})
	}
}
```

### Generator

The generator takes the object model and writes out Go code that produces the expected output. Any changes to Go code output by templ are made in this area.

Testing of the generator is carried out by creating a templ file, and a matching expected output file.

For example, `./generator/test-a-href` contains a templ file of:

```templ
package testahref

templ render() {
	<a href="javascript:alert(&#39;unaffected&#39;);">Ignored</a>
	<a href={ templ.URL("javascript:alert('should be sanitized')") }>Sanitized</a>
	<a href={ templ.SafeURL("javascript:alert('should not be sanitized')") }>Unsanitized</a>
}
```

It also contains an expected output file.

```html
<a href="javascript:alert(&#39;unaffected&#39;);">Ignored</a>
<a href="about:invalid#TemplFailedSanitizationURL">Sanitized</a>
<a href="javascript:alert(&#39;should not be sanitized&#39;)">Unsanitized</a>
```

These tests contribute towards the code coverage metrics by building an instrumented test CLI program. See the `test-cover` task in the `README.md` file.

### CLI

The command line interface for templ is used to generate Go code from templ files, format templ files, and run the LSP.

The code for this is at `./cmd/templ`.

Testing of the templ command line is done with unit tests to check the argument parsing.

The `templ generate` command is tested by generating templ files in the project, and testing that the expected output HTML is present.

### Runtime

The runtime is used by generated code, and by template authors, to serve template content over HTTP, and to carry out various operations.

It is in the root directory of the project at `./runtime.go`. The runtime is unit tested, as well as being tested as part of the `generate` tests.

### LSP

The LSP is structured within the command line interface, and proxies commands through to the `gopls` LSP.

### Docs

The docs are a Docusaurus project at `./docs`.

## Coding

### Build tasks

templ uses the `xc` task runner - https://github.com/joerdav/xc

If you run `xc` you can get see a list of the development tasks that can be run, or you can read the `README.md` file and see the `Tasks` section.

The most useful tasks for local development are:

* `install-snapshot` - this builds the templ CLI and installs it into `~/bin`. Ensure that this is in your path.
* `test` - this regenerates all templates, and runs the unit tests.
* `fmt` - run the `gofmt` tool to format all Go code.
* `lint` - run the same linting as run in the CI process.
* `docs-run` - run the Docusaurus documentation site.

### Commit messages

The project using https://www.conventionalcommits.org/en/v1.0.0/

Examples:

* `feat: support Go comments in templates, fixes #234"`

### Coding style

* Reduce nesting - i.e. prefer early returns over an `else` block, as per https://danp.net/posts/reducing-go-nesting/ or https://go.dev/doc/effective_go#if
* Use line breaks to separate "paragraphs" of code - don't use line breaks in between lines, or at the start/end of functions etc.
* Use the `fmt` and `lint` build tasks to format and lint your code before submitting a PR.

### LLM instructions

See additional coding standards at `.github/copilot-instructions.md`


================================================
FILE: LICENSE
================================================
MIT License

Copyright (c) 2021 Adrian Hesketh

Permission is hereby granted, free of charge, to any person obtaining a copy
of this software and associated documentation files (the "Software"), to deal
in the Software without restriction, including without limitation the rights
to use, copy, modify, merge, publish, distribute, sublicense, and/or sell
copies of the Software, and to permit persons to whom the Software is
furnished to do so, subject to the following conditions:

The above copyright notice and this permission notice shall be included in all
copies or substantial portions of the Software.

THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE
AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER
LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM,
OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE
SOFTWARE.


================================================
FILE: README.md
================================================
![templ](https://github.com/a-h/templ/raw/main/templ.png)

## An HTML templating language for Go that has great developer tooling.

![templ](ide-demo.gif)


## Documentation

See user documentation at https://templ.guide

<p align="center">
<a href="https://pkg.go.dev/github.com/a-h/templ"><img src="https://pkg.go.dev/badge/github.com/a-h/templ.svg" alt="Go Reference" /></a>
<a href="https://xcfile.dev"><img src="https://xcfile.dev/badge.svg" alt="xc compatible" /></a>
<a href="https://raw.githack.com/wiki/a-h/templ/coverage.html"><img src="https://github.com/a-h/templ/wiki/coverage.svg" alt="Go Coverage" /></a>
<a href="https://goreportcard.com/report/github.com/a-h/templ"><img src="https://goreportcard.com/badge/github.com/a-h/templ" alt="Go Report Card" /></a>
</p>

## Tasks

### version-set

Set the version of templ to the current version.

```sh
version set --template="0.3.%d"
```

### build

Build a local version.

```sh
version set --template="0.3.%d"
cd cmd/templ
go build
```

### install-snapshot

Build and install current version.

```sh
# Remove templ from the non-standard ~/bin/templ path
# that this command previously used.
rm -f ~/bin/templ
# Clear LSP logs.
rm -f cmd/templ/lspcmd/*.txt
# Update version.
version set --template="0.3.%d"
# Install to $GOPATH/bin or $HOME/go/bin
cd cmd/templ && go install
```

### build-snapshot

Use goreleaser to build the command line binary using goreleaser.

```sh
goreleaser build --snapshot --clean
```

### generate

Run templ generate using local version.

```sh
go run ./cmd/templ generate -include-version=false
```

### test

Run Go tests.

```sh
version set --template="0.3.%d"
go run ./cmd/templ generate -include-version=false
go test ./...
```

### test-short

Run Go tests.

```sh
version set --template="0.3.%d"
go run ./cmd/templ generate -include-version=false
go test ./... -short
```

### test-cover

Run Go tests.

```sh
# Create test profile directories.
mkdir -p coverage/fmt
mkdir -p coverage/generate
mkdir -p coverage/version
mkdir -p coverage/unit
# Build the test binary.
go build -cover -o ./coverage/templ-cover ./cmd/templ
# Run the covered generate command.
GOCOVERDIR=coverage/fmt ./coverage/templ-cover fmt .
GOCOVERDIR=coverage/generate ./coverage/templ-cover generate -include-version=false
GOCOVERDIR=coverage/version ./coverage/templ-cover version
# Run the unit tests.
go test -cover ./... -coverpkg ./... -args -test.gocoverdir="$PWD/coverage/unit"
# Display the combined percentage.
go tool covdata percent -i=./coverage/fmt,./coverage/generate,./coverage/version,./coverage/unit
# Generate a text coverage profile for tooling to use.
go tool covdata textfmt -i=./coverage/fmt,./coverage/generate,./coverage/version,./coverage/unit -o coverage.out
# Print total
go tool cover -func coverage.out | grep total
```

### test-cover-watch

interactive: true

```sh
gotestsum --watch -- -coverprofile=coverage.out
```

### test-fuzz

```sh
./parser/v2/fuzz.sh
./parser/v2/goexpression/fuzz.sh
```

### benchmark

Run benchmarks.

```sh
go run ./cmd/templ generate -include-version=false && go test ./... -bench=. -benchmem
```

### fmt

Format all Go and templ code.

```sh
gofmt -s -w .
go run ./cmd/templ fmt .
```

### lint

Run the lint operations that are run as part of the CI.

```sh
golangci-lint run --verbose
```

### ensure-generated

Ensure that templ files have been generated with the local version of templ, and that those files have been added to git.

Requires: generate

```sh
git diff --exit-code
```

### push-release-tag

Push a semantic version number to GitHub to trigger the release process.

```sh
version push --template="0.3.%d" --prefix="v"
```

### docs-run

Run the development server.

Directory: docs

```sh
npm run start
```

### docs-build

Build production docs site.

Directory: docs

```sh
npm run build
```



================================================
FILE: SECURITY.md
================================================
# Security Policy

## Supported Versions

The latest version of templ is supported.

## Reporting a Vulnerability

Use the "Security" tab in GitHub and fill out the "Report a vulnerability" form.


================================================
FILE: benchmarks/react/.gitignore
================================================
index.js
node_modules



================================================
FILE: benchmarks/react/README.md
================================================
# React benchmark

## Tasks

### install

```
npm i
```

### build

```sh
npm run build
```

### run

requires: build

```sh
npm start
```


================================================
FILE: benchmarks/react/package.json
================================================
{
  "name": "react-benchmark",
  "version": "1.0.0",
  "description": "",
  "main": "./src/index.jsx",
  "scripts": {
    "build": "esbuild ./src/index.jsx --bundle --outfile=index.js",
    "start": "node index.js"
  },
  "author": "",
  "license": "ISC",
  "dependencies": {
    "benchmark": "^2.1.4",
    "esbuild": "0.25.0",
    "microtime": "^3.0.0",
    "react": "^18.2.0",
    "react-dom": "^18.2.0"
  }
}


================================================
FILE: benchmarks/react/src/index.jsx
================================================
import * as React from 'react'
import * as Server from 'react-dom/server'
import Benchmark from 'benchmark';

const component = (p) =>
        <div>
                <h1>{p.Name}</h1>
                <div style={{ fontFamily: "sans-serif" }} id="test" data-contents="something with &#34;quotes&#34; and a &lt;tag&gt;">
                        <div>email:<a href="mailto: luiz@example.com">luiz@example.com</a></div>
                </div>
                <hr noshade /><hr optionA optionB optionC="other" /><hr noshade />
        </div>;

const p = {
        Name: "Luiz Bonfa",
        Email: "luiz@example.com",
};

// Benchmark.
// Outputs...
// Render test x 114,131 ops/sec ±0.27% (97 runs sampled)
// There are 1,000,000,000 nanoseconds in a second.
// 1,000,000,000ns / 114,131 ops = 8,757.5 ns per operation.
// The templ equivalent is 340 ns per operation.
const suite = new Benchmark.Suite;

const test = suite.add('Render test',
        () => Server.renderToString(component(p)))

test.on('cycle', (event) => {
        console.log(String(event.target));
});

test.run();


================================================
FILE: benchmarks/templ/README.md
================================================
# templ benchmark

Used to test code generation strategies for improvements to render time.

## Tasks

### run

```
go test -bench .
```

## Results as of 2023-08-17

```
go test -bench .
goos: darwin
goarch: arm64
pkg: github.com/a-h/templ/benchmarks/templ
BenchmarkTempl-10                3291883               369.1 ns/op           536 B/op          6 allocs/op
BenchmarkGoTemplate-10            481052              2475 ns/op            1400 B/op         38 allocs/op
BenchmarkIOWriteString-10       20353198                56.64 ns/op          320 B/op          1 allocs/op
PASS
ok      github.com/a-h/templ/benchmarks/templ   4.650s
```

React comes in at 1,000,000,000ns / 114,131 ops/s = 8,757.5 ns per operation.


================================================
FILE: benchmarks/templ/data.go
================================================
package testhtml

type Person struct {
	Name  string
	Email string
}


================================================
FILE: benchmarks/templ/render_test.go
================================================
package testhtml

import (
	"context"
	"html/template"
	"io"
	"strings"
	"testing"

	_ "embed"

	"github.com/a-h/templ/parser/v2"
)

func BenchmarkTemplRender(b *testing.B) {
	b.ReportAllocs()
	t := Render(Person{
		Name:  "Luiz Bonfa",
		Email: "luiz@example.com",
	})

	w := new(strings.Builder)
	for range b.N {
		err := t.Render(context.Background(), w)
		if err != nil {
			b.Errorf("failed to render: %v", err)
		}
		w.Reset()
	}
}

//go:embed template.templ
var parserBenchmarkTemplate string

func BenchmarkTemplParser(b *testing.B) {
	for range b.N {
		tf, err := parser.ParseString(parserBenchmarkTemplate)
		if err != nil {
			b.Fatal(err)
		}
		if tf.Package.Expression.Value == "" {
			b.Fatal("unexpected nil template")
		}
	}
}

var goTemplate = template.Must(template.New("example").Parse(`<div>
	<h1>{{.Name}}</h1>
	<div style="font-family: &#39;sans-serif&#39;" id="test" data-contents="something with &#34;quotes&#34; and a &lt;tag&gt;">
		<div>
			email:<a href="mailto: {{.Email}}">{{.Email}}</a></div>
		</div>
	</div>
	<hr noshade>
	<hr optionA optionB optionC="other">
	<hr noshade>
`))

func BenchmarkGoTemplateRender(b *testing.B) {
	w := new(strings.Builder)
	person := Person{
		Name:  "Luiz Bonfa",
		Email: "luiz@exapmle.com",
	}
	b.ReportAllocs()
	for range b.N {
		err := goTemplate.Execute(w, person)
		if err != nil {
			b.Errorf("failed to render: %v", err)
		}
		w.Reset()
	}
}

const html = `<div><h1>Luiz Bonfa</h1><div style="font-family: &#39;sans-serif&#39;" id="test" data-contents="something with &#34;quotes&#34; and a &lt;tag&gt;"><div>email:<a href="mailto: luiz@example.com">luiz@example.com</a></div></div></div><hr noshade><hr optionA optionB optionC="other"><hr noshade>`

func BenchmarkIOWriteString(b *testing.B) {
	b.ReportAllocs()
	w := new(strings.Builder)
	for range b.N {
		_, err := io.WriteString(w, html)
		if err != nil {
			b.Errorf("failed to render: %v", err)
		}
		w.Reset()
	}
}


================================================
FILE: benchmarks/templ/template.templ
================================================
package testhtml

templ Render(p Person) {
	<div>
		<h1>{ p.Name }</h1>
		<div style="font-family: 'sans-serif'" id="test" data-contents={ `something with "quotes" and a <tag>` }>
			<div>email:<a href={ templ.URL("mailto: " + p.Email) }>{ p.Email }</a></div>
		</div>
	</div>
	<hr noshade?={ true }/>
	<hr optionA optionB?={ true } optionC="other" optionD?={ false }/>
	<hr noshade/>
}


================================================
FILE: benchmarks/templ/template_templ.go
================================================
// Code generated by templ - DO NOT EDIT.

package testhtml

//lint:file-ignore SA4006 This context is only used if a nested component is present.

import "github.com/a-h/templ"
import templruntime "github.com/a-h/templ/runtime"

func Render(p Person) templ.Component {
	return templruntime.GeneratedTemplate(func(templ_7745c5c3_Input templruntime.GeneratedComponentInput) (templ_7745c5c3_Err error) {
		templ_7745c5c3_W, ctx := templ_7745c5c3_Input.Writer, templ_7745c5c3_Input.Context
		if templ_7745c5c3_CtxErr := ctx.Err(); templ_7745c5c3_CtxErr != nil {
			return templ_7745c5c3_CtxErr
		}
		templ_7745c5c3_Buffer, templ_7745c5c3_IsBuffer := templruntime.GetBuffer(templ_7745c5c3_W)
		if !templ_7745c5c3_IsBuffer {
			defer func() {
				templ_7745c5c3_BufErr := templruntime.ReleaseBuffer(templ_7745c5c3_Buffer)
				if templ_7745c5c3_Err == nil {
					templ_7745c5c3_Err = templ_7745c5c3_BufErr
				}
			}()
		}
		ctx = templ.InitializeContext(ctx)
		templ_7745c5c3_Var1 := templ.GetChildren(ctx)
		if templ_7745c5c3_Var1 == nil {
			templ_7745c5c3_Var1 = templ.NopComponent
		}
		ctx = templ.ClearChildren(ctx)
		templ_7745c5c3_Err = templruntime.WriteString(templ_7745c5c3_Buffer, 1, "<div><h1>")
		if templ_7745c5c3_Err != nil {
			return templ_7745c5c3_Err
		}
		var templ_7745c5c3_Var2 string
		templ_7745c5c3_Var2, templ_7745c5c3_Err = templ.JoinStringErrs(p.Name)
		if templ_7745c5c3_Err != nil {
			return templ.Error{Err: templ_7745c5c3_Err, FileName: `benchmarks/templ/template.templ`, Line: 5, Col: 14}
		}
		_, templ_7745c5c3_Err = templ_7745c5c3_Buffer.WriteString(templ.EscapeString(templ_7745c5c3_Var2))
		if templ_7745c5c3_Err != nil {
			return templ_7745c5c3_Err
		}
		templ_7745c5c3_Err = templruntime.WriteString(templ_7745c5c3_Buffer, 2, "</h1><div style=\"font-family: 'sans-serif'\" id=\"test\" data-contents=\"")
		if templ_7745c5c3_Err != nil {
			return templ_7745c5c3_Err
		}
		var templ_7745c5c3_Var3 string
		templ_7745c5c3_Var3, templ_7745c5c3_Err = templ.JoinStringErrs(`something with "quotes" and a <tag>`)
		if templ_7745c5c3_Err != nil {
			return templ.Error{Err: templ_7745c5c3_Err, FileName: `benchmarks/templ/template.templ`, Line: 6, Col: 104}
		}
		_, templ_7745c5c3_Err = templ_7745c5c3_Buffer.WriteString(templ.EscapeString(templ_7745c5c3_Var3))
		if templ_7745c5c3_Err != nil {
			return templ_7745c5c3_Err
		}
		templ_7745c5c3_Err = templruntime.WriteString(templ_7745c5c3_Buffer, 3, "\"><div>email:<a href=\"")
		if templ_7745c5c3_Err != nil {
			return templ_7745c5c3_Err
		}
		var templ_7745c5c3_Var4 templ.SafeURL
		templ_7745c5c3_Var4, templ_7745c5c3_Err = templ.JoinURLErrs(templ.URL("mailto: " + p.Email))
		if templ_7745c5c3_Err != nil {
			return templ.Error{Err: templ_7745c5c3_Err, FileName: `benchmarks/templ/template.templ`, Line: 7, Col: 55}
		}
		_, templ_7745c5c3_Err = templ_7745c5c3_Buffer.WriteString(templ.EscapeString(templ_7745c5c3_Var4))
		if templ_7745c5c3_Err != nil {
			return templ_7745c5c3_Err
		}
		templ_7745c5c3_Err = templruntime.WriteString(templ_7745c5c3_Buffer, 4, "\">")
		if templ_7745c5c3_Err != nil {
			return templ_7745c5c3_Err
		}
		var templ_7745c5c3_Var5 string
		templ_7745c5c3_Var5, templ_7745c5c3_Err = templ.JoinStringErrs(p.Email)
		if templ_7745c5c3_Err != nil {
			return templ.Error{Err: templ_7745c5c3_Err, FileName: `benchmarks/templ/template.templ`, Line: 7, Col: 67}
		}
		_, templ_7745c5c3_Err = templ_7745c5c3_Buffer.WriteString(templ.EscapeString(templ_7745c5c3_Var5))
		if templ_7745c5c3_Err != nil {
			return templ_7745c5c3_Err
		}
		templ_7745c5c3_Err = templruntime.WriteString(templ_7745c5c3_Buffer, 5, "</a></div></div></div><hr")
		if templ_7745c5c3_Err != nil {
			return templ_7745c5c3_Err
		}
		if true {
			templ_7745c5c3_Err = templruntime.WriteString(templ_7745c5c3_Buffer, 6, " noshade")
			if templ_7745c5c3_Err != nil {
				return templ_7745c5c3_Err
			}
		}
		templ_7745c5c3_Err = templruntime.WriteString(templ_7745c5c3_Buffer, 7, "><hr optionA")
		if templ_7745c5c3_Err != nil {
			return templ_7745c5c3_Err
		}
		if true {
			templ_7745c5c3_Err = templruntime.WriteString(templ_7745c5c3_Buffer, 8, " optionB")
			if templ_7745c5c3_Err != nil {
				return templ_7745c5c3_Err
			}
		}
		templ_7745c5c3_Err = templruntime.WriteString(templ_7745c5c3_Buffer, 9, " optionC=\"other\"")
		if templ_7745c5c3_Err != nil {
			return templ_7745c5c3_Err
		}
		if false {
			templ_7745c5c3_Err = templruntime.WriteString(templ_7745c5c3_Buffer, 10, " optionD")
			if templ_7745c5c3_Err != nil {
				return templ_7745c5c3_Err
			}
		}
		templ_7745c5c3_Err = templruntime.WriteString(templ_7745c5c3_Buffer, 11, "><hr noshade>")
		if templ_7745c5c3_Err != nil {
			return templ_7745c5c3_Err
		}
		return nil
	})
}

var _ = templruntime.GeneratedTemplate


================================================
FILE: cfg/cfg.go
================================================
// This package is inspired by the GOEXPERIMENT approach of allowing feature flags for experimenting with breaking changes.
package cfg

import (
	"os"
	"strings"
)

type Flags struct{}

var Experiment = parse()

func parse() *Flags {
	m := map[string]bool{}
	for _, f := range strings.Split(os.Getenv("TEMPL_EXPERIMENT"), ",") {
		m[strings.ToLower(f)] = true
	}

	return &Flags{}
}


================================================
FILE: cmd/templ/fmtcmd/main.go
================================================
package fmtcmd

import (
	"bytes"
	"errors"
	"fmt"
	"io"
	"log/slog"
	"os"
	"runtime"
	"time"

	"github.com/a-h/templ/cmd/templ/processor"
	"github.com/a-h/templ/internal/format"
	"github.com/natefinch/atomic"
)

type Arguments struct {
	FailIfChanged    bool
	ToStdout         bool
	StdinFilepath    string
	Files            []string
	WorkerCount      int
	PrettierCommand  string
	PrettierRequired bool
}

func Run(log *slog.Logger, stdin io.Reader, stdout io.Writer, args Arguments) (err error) {
	// If no files are provided, read from stdin and write to stdout.
	formatterConfig := format.Config{
		PrettierCommand:  args.PrettierCommand,
		PrettierRequired: args.PrettierRequired,
	}
	if len(args.Files) == 0 {
		src, err := io.ReadAll(stdin)
		if err != nil {
			return fmt.Errorf("failed to read from stdin: %w", err)
		}
		formatted, _, err := format.Templ(src, args.StdinFilepath, formatterConfig)
		if err != nil {
			return fmt.Errorf("failed to format stdin: %w", err)
		}
		if _, err = stdout.Write(formatted); err != nil {
			return fmt.Errorf("failed to write to stdout: %w", err)
		}
		return nil
	}
	// If files are provided, process each file.
	process := func(fileName string) (error, bool) {
		src, err := os.ReadFile(fileName)
		if err != nil {
			return fmt.Errorf("failed to read file %q: %w", fileName, err), false
		}
		formatted, changed, err := format.Templ(src, fileName, formatterConfig)
		if err != nil {
			return fmt.Errorf("failed to format file %q: %w", fileName, err), false
		}
		if !changed && !args.ToStdout {
			return nil, false
		}
		if args.ToStdout {
			if _, err := stdout.Write(formatted); err != nil {
				return fmt.Errorf("failed to write to stdout: %w", err), false
			}
			return nil, true
		}
		if err := atomic.WriteFile(fileName, bytes.NewBuffer(formatted)); err != nil {
			return fmt.Errorf("failed to write file %q: %w", fileName, err), false
		}
		return nil, true
	}
	dir := args.Files[0]
	return NewFormatter(log, dir, process, args.WorkerCount, args.FailIfChanged).Run()
}

type Formatter struct {
	Log          *slog.Logger
	Dir          string
	Process      func(fileName string) (error, bool)
	WorkerCount  int
	FailIfChange bool
}

func NewFormatter(log *slog.Logger, dir string, process func(fileName string) (error, bool), workerCount int, failIfChange bool) *Formatter {
	f := &Formatter{
		Log:          log,
		Dir:          dir,
		Process:      process,
		WorkerCount:  workerCount,
		FailIfChange: failIfChange,
	}
	if f.WorkerCount == 0 {
		f.WorkerCount = runtime.NumCPU()
	}
	return f
}

func (f *Formatter) Run() (err error) {
	var errs []error
	changesMade := 0
	start := time.Now()
	results := make(chan processor.Result)
	f.Log.Debug("Walking directory", slog.String("path", f.Dir))
	go processor.Process(f.Dir, f.Process, f.WorkerCount, results)
	var successCount, errorCount int
	for r := range results {
		if r.ChangesMade {
			changesMade += 1
		}
		if r.Error != nil {
			f.Log.Error(r.FileName, slog.Any("error", r.Error))
			errorCount++
			errs = append(errs, r.Error)
			continue
		}
		f.Log.Debug(r.FileName, slog.Duration("duration", r.Duration))
		successCount++
	}

	if f.FailIfChange && changesMade > 0 {
		f.Log.Error("Templates were valid but not properly formatted", slog.Int("count", successCount+errorCount), slog.Int("changed", changesMade), slog.Int("errors", errorCount), slog.Duration("duration", time.Since(start)))
		return fmt.Errorf("templates were not formatted properly")
	}

	f.Log.Info("Format Complete", slog.Int("count", successCount+errorCount), slog.Int("errors", errorCount), slog.Int("changed", changesMade), slog.Duration("duration", time.Since(start)))

	if err = errors.Join(errs...); err != nil {
		return fmt.Errorf("formatting failed: %w", err)
	}

	return nil
}


================================================
FILE: cmd/templ/fmtcmd/main_test.go
================================================
package fmtcmd

import (
	_ "embed"
	"fmt"
	"io"
	"log/slog"
	"os"
	"path/filepath"
	"strings"
	"testing"

	"github.com/google/go-cmp/cmp"
	"golang.org/x/tools/txtar"
)

//go:embed testdata.txtar
var testDataTxTar []byte

type testProject struct {
	dir       string
	cleanup   func() error
	testFiles map[string]testFile
}

type testFile struct {
	name            string
	input, expected string
}

func setupProjectDir() (tp testProject, err error) {
	tp.dir, err = os.MkdirTemp("", "fmtcmd_test_*")
	if err != nil {
		return tp, fmt.Errorf("failed to make test dir: %w", err)
	}
	tp.testFiles = make(map[string]testFile)
	testData := txtar.Parse(testDataTxTar)
	for i := 0; i < len(testData.Files); i += 2 {
		file := testData.Files[i]
		err = os.WriteFile(filepath.Join(tp.dir, file.Name), file.Data, 0660)
		if err != nil {
			return tp, fmt.Errorf("failed to write file: %w", err)
		}
		tp.testFiles[file.Name] = testFile{
			name:     filepath.Join(tp.dir, file.Name),
			input:    string(file.Data),
			expected: string(testData.Files[i+1].Data),
		}
	}
	tp.cleanup = func() error {
		if err := os.RemoveAll(tp.dir); err != nil {
			return fmt.Errorf("failed to remove test directory %q: %w", tp.dir, err)
		}
		return nil
	}
	return tp, nil
}

func TestFormat(t *testing.T) {
	log := slog.New(slog.NewJSONHandler(io.Discard, nil))
	t.Run("can format a single file from stdin to stdout", func(t *testing.T) {
		tp, err := setupProjectDir()
		if err != nil {
			t.Fatalf("failed to setup project dir: %v", err)
		}
		defer func() {
			if err := tp.cleanup(); err != nil {
				t.Errorf("cleanup error: %v", err)
			}
		}()
		stdin := strings.NewReader(tp.testFiles["a.templ"].input)
		stdout := new(strings.Builder)
		if err = Run(log, stdin, stdout, Arguments{
			ToStdout: true,
		}); err != nil {
			t.Fatalf("failed to run format command: %v", err)
		}
		if diff := cmp.Diff(tp.testFiles["a.templ"].expected, stdout.String()); diff != "" {
			t.Error(diff)
		}
	})
	t.Run("can process a single file to stdout", func(t *testing.T) {
		tp, err := setupProjectDir()
		if err != nil {
			t.Fatalf("failed to setup project dir: %v", err)
		}
		defer func() {
			if err := tp.cleanup(); err != nil {
				t.Errorf("cleanup error: %v", err)
			}
		}()
		stdout := new(strings.Builder)
		if err = Run(log, nil, stdout, Arguments{
			ToStdout: true,
			Files: []string{
				tp.testFiles["a.templ"].name,
			},
			FailIfChanged: false,
		}); err != nil {
			t.Fatalf("failed to run format command: %v", err)
		}
		if diff := cmp.Diff(tp.testFiles["a.templ"].expected, stdout.String()); diff != "" {
			t.Error(diff)
		}
	})
	t.Run("can process a single file in place", func(t *testing.T) {
		tp, err := setupProjectDir()
		if err != nil {
			t.Fatalf("failed to setup project dir: %v", err)
		}
		defer func() {
			if err := tp.cleanup(); err != nil {
				t.Errorf("cleanup error: %v", err)
			}
		}()
		if err = Run(log, nil, nil, Arguments{
			Files: []string{
				tp.testFiles["a.templ"].name,
			},
			FailIfChanged: false,
		}); err != nil {
			t.Fatalf("failed to run format command: %v", err)
		}
		data, err := os.ReadFile(tp.testFiles["a.templ"].name)
		if err != nil {
			t.Fatalf("failed to read file: %v", err)
		}
		if diff := cmp.Diff(tp.testFiles["a.templ"].expected, string(data)); diff != "" {
			t.Error(diff)
		}
	})

	t.Run("fails when fail flag used and change occurs", func(t *testing.T) {
		tp, err := setupProjectDir()
		if err != nil {
			t.Fatalf("failed to setup project dir: %v", err)
		}
		defer func() {
			if err := tp.cleanup(); err != nil {
				t.Errorf("cleanup error: %v", err)
			}
		}()
		if err = Run(log, nil, nil, Arguments{
			Files: []string{
				tp.testFiles["a.templ"].name,
			},
			FailIfChanged: true,
		}); err == nil {
			t.Fatal("command should have exited with an error and did not")
		}
		data, err := os.ReadFile(tp.testFiles["a.templ"].name)
		if err != nil {
			t.Fatalf("failed to read file: %v", err)
		}
		if diff := cmp.Diff(tp.testFiles["a.templ"].expected, string(data)); diff != "" {
			t.Error(diff)
		}
	})

	t.Run("passes when fail flag used and no change occurs", func(t *testing.T) {
		tp, err := setupProjectDir()
		if err != nil {
			t.Fatalf("failed to setup project dir: %v", err)
		}
		defer func() {
			if err := tp.cleanup(); err != nil {
				t.Errorf("cleanup error: %v", err)
			}
		}()
		if err = Run(log, nil, nil, Arguments{
			Files: []string{
				tp.testFiles["c.templ"].name,
			},
			FailIfChanged: true,
		}); err != nil {
			t.Fatalf("failed to run format command: %v", err)
		}
		data, err := os.ReadFile(tp.testFiles["c.templ"].name)
		if err != nil {
			t.Fatalf("failed to read file: %v", err)
		}
		if diff := cmp.Diff(tp.testFiles["c.templ"].expected, string(data)); diff != "" {
			t.Error(diff)
		}
	})
}


================================================
FILE: cmd/templ/fmtcmd/testdata.txtar
================================================
-- a.templ --
package test

templ a() {
	<div><p class={templ.Class("mapped")}>A
</p></div>
}
-- a.templ --
package test

templ a() {
	<div>
		<p class={ templ.Class("mapped") }>
			A
		</p>
	</div>
}
-- b.templ --
package test

templ b() {
	<div><p>B
</p></div>
}
-- b.templ --
package test

templ b() {
	<div>
		<p>
			B
		</p>
	</div>
}
-- c.templ --
package test

templ c() {
	<div>
		<p>
			C
		</p>
	</div>
}
-- c.templ --
package test

templ c() {
	<div>
		<p>
			C
		</p>
	</div>
}
-- d.templ --
package test

templ c(s string) {
  <div s= {s}/>
}
-- d.templ --
package test

templ c(s string) {
  <div s={ s }/>
}


================================================
FILE: cmd/templ/generatecmd/cmd.go
================================================
package generatecmd

import (
	"context"
	"crypto/tls"
	"crypto/x509"
	"errors"
	"fmt"
	"io/fs"
	"log/slog"
	"net/http"
	"net/url"
	"os"
	"path"
	"path/filepath"
	"strings"
	"sync"
	"time"

	"github.com/a-h/templ/internal/skipdir"
	templruntime "github.com/a-h/templ/runtime"
	"golang.org/x/sync/errgroup"

	"github.com/a-h/templ"
	"github.com/a-h/templ/cmd/templ/generatecmd/modcheck"
	"github.com/a-h/templ/cmd/templ/generatecmd/proxy"
	"github.com/a-h/templ/cmd/templ/generatecmd/run"
	"github.com/a-h/templ/cmd/templ/generatecmd/watcher"
	"github.com/a-h/templ/generator"
	"github.com/cenkalti/backoff/v4"
	"github.com/cli/browser"
	"github.com/fsnotify/fsnotify"
)

func NewGenerate(log *slog.Logger, args Arguments) (g *Generate, err error) {
	g = &Generate{
		Log:  log,
		Args: args,
	}
	return g, nil
}

type Generate struct {
	Log  *slog.Logger
	Args Arguments
}

type GenerationEvent struct {
	Event                fsnotify.Event
	WatchedFileUpdated   bool
	TemplFileTextUpdated bool
	TemplFileGoUpdated   bool
}

func (cmd Generate) Run(ctx context.Context) (err error) {
	if cmd.Args.NotifyProxy {
		return proxy.NotifyProxy(cmd.Args.ProxyBind, cmd.Args.ProxyPort)
	}
	if cmd.Args.PPROFPort > 0 {
		go func() {
			_ = http.ListenAndServe(fmt.Sprintf("localhost:%d", cmd.Args.PPROFPort), nil)
		}()
	}

	// Use absolute path.
	if !path.IsAbs(cmd.Args.Path) {
		cmd.Args.Path, err = filepath.Abs(cmd.Args.Path)
		if err != nil {
			return fmt.Errorf("failed to get absolute path: %w", err)
		}
	}

	// Configure generator.
	var opts []generator.GenerateOpt
	if cmd.Args.IncludeVersion {
		opts = append(opts, generator.WithVersion(templ.Version()))
	}
	if cmd.Args.IncludeTimestamp {
		opts = append(opts, generator.WithTimestamp(time.Now()))
	}

	// Check the version of the templ module.
	if err := modcheck.Check(cmd.Args.Path); err != nil {
		cmd.Log.Warn("templ version check: " + err.Error())
	}

	cmd.Log.Debug("Creating filesystem event handler")
	fseh := NewFSEventHandler(
		cmd.Log,
		cmd.Args.Path,
		cmd.Args.Watch,
		opts,
		cmd.Args.GenerateSourceMapVisualisations,
		cmd.Args.KeepOrphanedFiles,
		cmd.Args.FileWriter,
		cmd.Args.Lazy,
	)

	// If we're processing a single file, don't bother setting up the channels/multithreaing.
	if cmd.Args.FileName != "" {
		_, err = fseh.HandleEvent(ctx, fsnotify.Event{
			Name: cmd.Args.FileName,
			Op:   fsnotify.Create,
		})
		return err
	}

	// Start timer.
	start := time.Now()

	// For the initial filesystem walk and subsequent (optional) fsnotify events.
	events := make(chan fsnotify.Event)
	// For errs from the watcher.
	errs := make(chan error)

	// Start process to push events into the events channel.
	grp, ctx := errgroup.WithContext(ctx)
	grp.Go(func() error {
		defer close(events)
		cmd.walkAndWatch(ctx, events, errs)
		return nil
	})

	// For triggering actions after generation has completed.
	postGeneration := make(chan *GenerationEvent, 256)

	// Start process to handle events.
	grp.Go(func() error {
		defer close(postGeneration)
		cmd.handleEvents(ctx, events, errs, fseh, postGeneration)
		return nil
	})

	// Start process to handle post-generation events.
	var updates int
	grp.Go(func() error {
		defer close(errs)
		updates, err = cmd.handlePostGenerationEvents(ctx, postGeneration)
		return err
	})

	// Read errors.
	var errorCount int
	for err := range errs {
		if err == nil {
			continue
		}
		if errors.Is(err, FatalError{}) {
			cmd.Log.Debug("Fatal error, exiting")
			return err
		}
		cmd.Log.Error("Error", slog.Any("error", err))
		errorCount++
	}

	// Wait for everything to complete.
	cmd.Log.Debug("Waiting for processes to complete")
	if err = grp.Wait(); err != nil {
		return err
	}
	if cmd.Args.Command != "" {
		cmd.Log.Debug("Killing command", slog.String("command", cmd.Args.Command))
		if err := run.KillAll(); err != nil {
			cmd.Log.Error("Error killing command", slog.Any("error", err))
		}
	}

	// Clean up temporary watch mode text files.
	if err := cmd.deleteWatchModeTextFiles(); err != nil {
		cmd.Log.Warn("Failed to delete watch mode text files", slog.Any("error", err))
	}

	// Check for errors after everything has completed.
	if errorCount > 0 {
		return fmt.Errorf("generation completed with %d errors", errorCount)
	}

	cmd.Log.Info("Complete", slog.Int("updates", updates), slog.Duration("duration", time.Since(start)))
	return nil
}

func (cmd Generate) groupUntilNoMessagesReceivedFor100ms(postGeneration chan *GenerationEvent) (grouped *GenerationEvent, updates int, ok bool, err error) {
	timeout := time.NewTimer(time.Hour * 24 * 365)
loop:
	for {
		select {
		case ge := <-postGeneration:
			if ge == nil {
				cmd.Log.Debug("Post-generation event channel closed, exiting")
				return nil, 0, false, nil
			}
			if grouped == nil {
				grouped = ge
			}
			grouped.WatchedFileUpdated = grouped.WatchedFileUpdated || ge.WatchedFileUpdated
			grouped.TemplFileTextUpdated = grouped.TemplFileTextUpdated || ge.TemplFileTextUpdated
			grouped.TemplFileGoUpdated = grouped.TemplFileGoUpdated || ge.TemplFileGoUpdated
			if grouped.WatchedFileUpdated || grouped.TemplFileTextUpdated || grouped.TemplFileGoUpdated {
				updates++
			}
			// Now we have received an event, wait for 100ms.
			// If no further messages are received in that time, the timeout will trigger.
			timeout = time.NewTimer(time.Millisecond * 100)
		case <-timeout.C:
			// If grouped is nil, or if no updates were made, reset the timer and continue waiting.
			if grouped == nil || (!grouped.WatchedFileUpdated && !grouped.TemplFileTextUpdated && !grouped.TemplFileGoUpdated) {
				timeout = time.NewTimer(time.Hour * 24 * 365)
				continue loop
			}
			// We have a grouped event, and no events have been sent in the last 100ms, so we need to return.
			return grouped, updates, true, nil
		}
	}
}

func (cmd Generate) handlePostGenerationEvents(ctx context.Context, postGeneration chan *GenerationEvent) (updates int, err error) {
	cmd.Log.Debug("Starting post-generation handler")
	var p *proxy.Handler
loop:
	for {
		grouped, updated, ok, err := cmd.groupUntilNoMessagesReceivedFor100ms(postGeneration)
		if err != nil {
			return 0, fmt.Errorf("error grouping post-generation events: %w", err)
		}
		if !ok {
			break loop
		}

		// The Go application needs to be restarted if any watched non-templ watched files (i.e. non-templ Go files)
		// were updated, or if any Go code within a templ file was updated.
		needsRestart := grouped.WatchedFileUpdated || grouped.TemplFileGoUpdated
		// If the text in a templ file, or any other changes have happened, reload the browser.
		needsBrowserReload := grouped.TemplFileTextUpdated || grouped.TemplFileGoUpdated || grouped.WatchedFileUpdated

		cmd.Log.Info("Post-generation event received, processing...", slog.Bool("needsRestart", needsRestart), slog.Bool("needsBrowserReload", needsBrowserReload))
		updates += updated

		if cmd.Args.Command != "" && needsRestart {
			cmd.Log.Info("Executing command", slog.String("command", cmd.Args.Command))
			if cmd.Args.Watch {
				if err := os.Setenv("TEMPL_DEV_MODE", "true"); err != nil {
					cmd.Log.Error("Error setting TEMPL_DEV_MODE environment variable", slog.Any("error", err))
				}
				// Check that the path is absolute.
				// It should have already been made absolute at the start of the Run method, but just in case, we need to make sure it's absolute before setting it as an environment variable.
				if !filepath.IsAbs(cmd.Args.Path) {
					cmd.Log.Error("Path is not absolute, this may cause issues with the command execution", slog.String("path", cmd.Args.Path))
				}
				// Evaluate symlinks to match the behavior in runtime/watchmode.go.
				watchRoot := cmd.Args.Path
				if resolved, err := filepath.EvalSymlinks(watchRoot); err == nil {
					watchRoot = resolved
				}
				if err := os.Setenv("TEMPL_DEV_MODE_WATCH_ROOT", watchRoot); err != nil {
					cmd.Log.Error("Error setting TEMPL_DEV_MODE_WATCH_ROOT environment variable", slog.Any("error", err))
				}
			}
			if _, err := run.Run(ctx, cmd.Args.Path, cmd.Args.Command); err != nil {
				cmd.Log.Error("Error executing command", slog.Any("error", err))
			}
		}
		if cmd.Args.Proxy != "" {
			if p == nil {
				cmd.Log.Debug("Starting proxy...")
				p, err = cmd.startProxy()
				if err != nil {
					cmd.Log.Error("Failed to start proxy", slog.Any("error", err))
				}
			}
			if needsBrowserReload {
				cmd.Log.Debug("Sending reload event")
				p.SendSSE("message", "reload")
			}
		}
	}
	return updates, nil
}

func (cmd Generate) handleEvents(ctx context.Context, events chan fsnotify.Event, errs chan error, fseh *FSEventHandler, postGeneration chan *GenerationEvent) {
	var eventsWG sync.WaitGroup
	sem := make(chan struct{}, cmd.Args.WorkerCount)
	cmd.Log.Debug("Starting event handler")
	for event := range events {
		eventsWG.Add(1)
		sem <- struct{}{}
		go func(event fsnotify.Event) {
			cmd.Log.Debug("Processing file", slog.String("file", event.Name))
			defer eventsWG.Done()
			defer func() { <-sem }()
			r, err := fseh.HandleEvent(ctx, event)
			if err != nil {
				errs <- err
			}
			if !r.WatchedFileUpdated && !r.TemplFileTextUpdated && !r.TemplFileGoUpdated {
				cmd.Log.Debug("File not updated", slog.String("file", event.Name))
				return
			}
			e := &GenerationEvent{
				Event:                event,
				WatchedFileUpdated:   r.WatchedFileUpdated,
				TemplFileTextUpdated: r.TemplFileTextUpdated,
				TemplFileGoUpdated:   r.TemplFileGoUpdated,
			}
			cmd.Log.Debug("File updated", slog.String("file", event.Name))
			postGeneration <- e
		}(event)
	}
	// Wait for all events to be processed before closing.
	eventsWG.Wait()
}

func (cmd *Generate) walkAndWatch(ctx context.Context, events chan fsnotify.Event, errs chan error) {
	cmd.Log.Debug("Walking directory", slog.String("path", cmd.Args.Path), slog.Bool("devMode", cmd.Args.Watch))
	if err := watcher.WalkFiles(ctx, cmd.Args.Path, cmd.Args.WatchPattern, cmd.Args.IgnorePattern, events); err != nil {
		cmd.Log.Error("WalkFiles failed, exiting", slog.Any("error", err))
		errs <- FatalError{Err: fmt.Errorf("failed to walk files: %w", err)}
		return
	}
	if !cmd.Args.Watch {
		cmd.Log.Debug("Dev mode not enabled, process can finish early")
		return
	}
	cmd.Log.Info("Watching files")
	rw, err := watcher.Recursive(ctx, cmd.Args.WatchPattern, cmd.Args.IgnorePattern, events, errs)
	if err != nil {
		cmd.Log.Error("Recursive watcher setup failed, exiting", slog.Any("error", err))
		errs <- FatalError{Err: fmt.Errorf("failed to setup recursive watcher: %w", err)}
		return
	}
	if err = rw.Add(cmd.Args.Path); err != nil {
		cmd.Log.Error("Failed to add path to watcher", slog.Any("error", err))
		errs <- FatalError{Err: fmt.Errorf("failed to add path to watcher: %w", err)}
		return
	}
	defer func() {
		if err := rw.Close(); err != nil {
			cmd.Log.Error("Failed to close watcher", slog.Any("error", err))
		}
	}()
	cmd.Log.Debug("Waiting for context to be cancelled to stop watching files")
	<-ctx.Done()
}

func (cmd *Generate) deleteWatchModeTextFiles() error {
	return fs.WalkDir(os.DirFS(cmd.Args.Path), ".", func(path string, info os.DirEntry, err error) error {
		if err != nil {
			return nil
		}
		absPath, err := filepath.Abs(filepath.Join(cmd.Args.Path, path))
		if err != nil {
			return nil
		}
		if info.IsDir() && skipdir.ShouldSkip(absPath) {
			return filepath.SkipDir
		}
		if !strings.HasSuffix(absPath, "_templ.go") && !strings.HasSuffix(absPath, ".templ") {
			return nil
		}
		watchModeFileName := templruntime.GetDevModeTextFileName(absPath)
		if err := os.Remove(watchModeFileName); err != nil && !errors.Is(err, os.ErrNotExist) {
			cmd.Log.Warn("Failed to remove watch mode text file", slog.Any("error", err))
		}
		return nil
	})
}

func (cmd *Generate) createTLSTransport() *http.Transport {
	certPEM, err := os.ReadFile(cmd.Args.ProxyTLSCrt)
	if err != nil {
		cmd.Log.Error("Failed to read TLS certificate file", slog.Any("error", err))
		return nil
	}
	certPool := x509.NewCertPool()
	if !certPool.AppendCertsFromPEM(certPEM) {
		cmd.Log.Error("Failed to append certificate to pool")
		return nil
	}
	return &http.Transport{
		TLSClientConfig: &tls.Config{RootCAs: certPool},
	}
}

func (cmd *Generate) startProxy() (p *proxy.Handler, err error) {
	var target *url.URL
	target, err = url.Parse(cmd.Args.Proxy)
	if err != nil {
		return nil, FatalError{Err: fmt.Errorf("failed to parse proxy URL: %w", err)}
	}
	scheme := "http"
	if cmd.Args.ProxyTLSCrt != "" && cmd.Args.ProxyTLSKey != "" {
		scheme = "https"
	}
	p = proxy.New(cmd.Log, scheme, cmd.Args.ProxyBind, cmd.Args.ProxyPort, target)
	go func() {
		cmd.Log.Info("Proxying", slog.String("from", p.URL), slog.String("to", p.Target.String()))
		server := &http.Server{
			Addr:    fmt.Sprintf("%s:%d", cmd.Args.ProxyBind, cmd.Args.ProxyPort),
			Handler: p,
		}
		// Configure TLS if certificates are provided.
		if cmd.Args.ProxyTLSCrt != "" && cmd.Args.ProxyTLSKey != "" {
			cert, err := tls.LoadX509KeyPair(cmd.Args.ProxyTLSCrt, cmd.Args.ProxyTLSKey)
			if err != nil {
				cmd.Log.Error("Failed to load TLS certificates", slog.Any("error", err))
				return
			}
			server.TLSConfig = &tls.Config{Certificates: []tls.Certificate{cert}}
			if err = server.ListenAndServeTLS(cmd.Args.ProxyTLSCrt, cmd.Args.ProxyTLSKey); err != nil {
				cmd.Log.Error("Proxy failed", slog.Any("error", err))
			}
			return
		}
		if err := server.ListenAndServe(); err != nil {
			cmd.Log.Error("Proxy failed", slog.Any("error", err))
		}
	}()
	if !cmd.Args.OpenBrowser {
		cmd.Log.Debug("Not opening browser")
		return p, nil
	}
	go func() {
		cmd.Log.Debug("Waiting for proxy to be ready", slog.String("url", p.URL))
		backoff := backoff.NewExponentialBackOff()
		backoff.InitialInterval = time.Second
		var client http.Client
		client.Timeout = 1 * time.Second
		// Configure TLS with CA pool for self-signed certificates on localhost.
		if cmd.Args.ProxyTLSCrt != "" && cmd.Args.ProxyTLSKey != "" {
			client.Transport = cmd.createTLSTransport()
		}
		for {
			if resp, err := client.Get(p.URL); err == nil {
				if resp.StatusCode != http.StatusBadGateway {
					break
				}
			}
			d := backoff.NextBackOff()
			cmd.Log.Debug("Proxy not ready, retrying", slog.String("url", p.URL), slog.Any("backoff", d))
			time.Sleep(d)
		}
		if err := browser.OpenURL(p.URL); err != nil {
			cmd.Log.Error("Failed to open browser", slog.Any("error", err))
		}
	}()
	return p, nil
}


================================================
FILE: cmd/templ/generatecmd/eventhandler.go
================================================
package generatecmd

import (
	"bufio"
	"bytes"
	"context"
	"crypto/sha256"
	"fmt"
	"go/format"
	"go/scanner"
	"go/token"
	"io"
	"log/slog"
	"os"
	"path"
	"path/filepath"
	"strings"
	"time"

	"github.com/a-h/templ/cmd/templ/visualize"
	"github.com/a-h/templ/generator"
	"github.com/a-h/templ/internal/syncmap"
	"github.com/a-h/templ/internal/syncset"
	"github.com/a-h/templ/parser/v2"
	"github.com/a-h/templ/runtime"
	"github.com/fsnotify/fsnotify"
	"golang.org/x/sync/errgroup"
)

type FileWriterFunc func(name string, contents []byte) error

func FileWriter(fileName string, contents []byte) error {
	return os.WriteFile(fileName, contents, 0o644)
}

func WriterFileWriter(w io.Writer) FileWriterFunc {
	return func(_ string, contents []byte) error {
		_, err := w.Write(contents)
		return err
	}
}

func NewFSEventHandler(
	log *slog.Logger,
	dir string,
	devMode bool,
	genOpts []generator.GenerateOpt,
	genSourceMapVis bool,
	keepOrphanedFiles bool,
	fileWriter FileWriterFunc,
	lazy bool,
) *FSEventHandler {
	if !path.IsAbs(dir) {
		dir, _ = filepath.Abs(dir)
	}
	fseh := &FSEventHandler{
		Log:                   log,
		dir:                   dir,
		fileNameToLastModTime: syncmap.New[string, time.Time](),
		fileNameToError:       syncset.New[string](),
		fileNameToOutput:      syncmap.New[string, generator.GeneratorOutput](),
		devMode:               devMode,
		hashes:                syncmap.New[string, [sha256.Size]byte](),
		genOpts:               genOpts,
		genSourceMapVis:       genSourceMapVis,
		keepOrphanedFiles:     keepOrphanedFiles,
		writer:                fileWriter,
		lazy:                  lazy,
	}
	return fseh
}

type FSEventHandler struct {
	Log *slog.Logger
	// dir is the root directory being processed.
	dir                   string
	fileNameToLastModTime *syncmap.Map[string, time.Time]
	fileNameToError       *syncset.Set[string]
	fileNameToOutput      *syncmap.Map[string, generator.GeneratorOutput]
	devMode               bool
	hashes                *syncmap.Map[string, [sha256.Size]byte]
	genOpts               []generator.GenerateOpt
	genSourceMapVis       bool
	Errors                []error
	keepOrphanedFiles     bool
	writer                FileWriterFunc
	lazy                  bool
}

type GenerateResult struct {
	// WatchedFileUpdated indicates that a file matching the watch pattern was updated.
	WatchedFileUpdated bool
	// TemplFileTextUpdated indicates that text literals were updated.
	TemplFileTextUpdated bool
	// TemplFileGoUpdated indicates that Go expressions were updated.
	TemplFileGoUpdated bool
}

func (h *FSEventHandler) HandleEvent(ctx context.Context, event fsnotify.Event) (result GenerateResult, err error) {
	// Handle _templ.go files.
	if !event.Has(fsnotify.Remove) && strings.HasSuffix(event.Name, "_templ.go") {
		_, err = os.Stat(strings.TrimSuffix(event.Name, "_templ.go") + ".templ")
		if !os.IsNotExist(err) {
			return GenerateResult{}, err
		}
		// File is orphaned.
		if h.keepOrphanedFiles {
			return GenerateResult{}, nil
		}
		h.Log.Debug("Deleting orphaned Go file", slog.String("file", event.Name))
		if err = os.Remove(event.Name); err != nil {
			h.Log.Warn("Failed to remove orphaned file", slog.Any("error", err))
		}
		return GenerateResult{WatchedFileUpdated: false, TemplFileGoUpdated: true, TemplFileTextUpdated: false}, nil
	}

	// If the file hasn't been updated since the last time we processed it, ignore it.
	fileInfo, err := os.Stat(event.Name)
	if err != nil {
		return GenerateResult{}, fmt.Errorf("failed to stat %q: %w", event.Name, err)
	}
	mustBeInTheFuture := func(previous, updated time.Time) bool {
		return updated.After(previous)
	}
	updatedModTime := h.fileNameToLastModTime.CompareAndSwap(event.Name, mustBeInTheFuture, fileInfo.ModTime())
	if !updatedModTime {
		h.Log.Debug("Skipping file because it wasn't updated", slog.String("file", event.Name))
		return GenerateResult{}, nil
	}

	// Process anything that isn't a templ file.
	if !strings.HasSuffix(event.Name, ".templ") {
		if h.devMode {
			h.Log.Info("Watched file updated", slog.String("file", event.Name))
		}
		result.WatchedFileUpdated = true
		return result, nil
	}

	// Handle templ files.

	// If the go file is newer than the templ file, skip generation, because it's up-to-date.
	if h.lazy && goFileIsUpToDate(event.Name, fileInfo.ModTime()) {
		h.Log.Debug("Skipping file because the Go file is up-to-date", slog.String("file", event.Name))
		return GenerateResult{}, nil
	}

	// Start a processor.
	start := time.Now()
	var diag []parser.Diagnostic
	result, diag, err = h.generate(ctx, event.Name)
	if err != nil {
		h.fileNameToError.Set(event.Name)
		return result, fmt.Errorf("failed to generate code for %q: %w", event.Name, err)
	}
	if len(diag) > 0 {
		for _, d := range diag {
			h.Log.Warn(d.Message,
				slog.String("from", fmt.Sprintf("%d:%d", d.Range.From.Line, d.Range.From.Col)),
				slog.String("to", fmt.Sprintf("%d:%d", d.Range.To.Line, d.Range.To.Col)),
			)
		}
		return result, nil
	}
	if errorCleared := h.fileNameToError.Delete(event.Name); errorCleared {
		h.Log.Info("Error cleared", slog.String("file", event.Name), slog.Int("errors", h.fileNameToError.Count()))
	}
	h.Log.Debug("Generated code", slog.String("file", event.Name), slog.Duration("in", time.Since(start)))

	return result, nil
}

func goFileIsUpToDate(templFileName string, templFileLastMod time.Time) (upToDate bool) {
	goFileName := strings.TrimSuffix(templFileName, ".templ") + "_templ.go"
	goFileInfo, err := os.Stat(goFileName)
	if err != nil {
		return false
	}
	return goFileInfo.ModTime().After(templFileLastMod)
}

// generate Go code for a single template.
// If a basePath is provided, the filename included in error messages is relative to it.
func (h *FSEventHandler) generate(ctx context.Context, fileName string) (result GenerateResult, diagnostics []parser.Diagnostic, err error) {
	t, err := parser.Parse(fileName)
	if err != nil {
		return GenerateResult{}, nil, fmt.Errorf("%s parsing error: %w", fileName, err)
	}
	targetFileName := strings.TrimSuffix(fileName, ".templ") + "_templ.go"

	// Only use relative filenames to the basepath for filenames in runtime error messages.
	absFilePath, err := filepath.Abs(fileName)
	if err != nil {
		return GenerateResult{}, nil, fmt.Errorf("failed to get absolute path for %q: %w", fileName, err)
	}
	relFilePath, err := filepath.Rel(h.dir, absFilePath)
	if err != nil {
		return GenerateResult{}, nil, fmt.Errorf("failed to get relative path for %q: %w", fileName, err)
	}
	// Convert Windows file paths to Unix-style for consistency.
	relFilePath = filepath.ToSlash(relFilePath)

	var b bytes.Buffer
	generatorOutput, err := generator.Generate(t, &b, append(h.genOpts, generator.WithFileName(relFilePath))...)
	if err != nil {
		return GenerateResult{}, nil, fmt.Errorf("%s generation error: %w", fileName, err)
	}

	formattedGoCode, err := format.Source(b.Bytes())
	if err != nil {
		err = remapErrorList(err, generatorOutput.SourceMap, fileName)
		return GenerateResult{}, nil, fmt.Errorf("%s source formatting error %w", fileName, err)
	}

	// Hash output, and write out the file if the goCodeHash has changed.
	goCodeHash := sha256.Sum256(formattedGoCode)
	if h.hashes.CompareAndSwap(targetFileName, syncmap.UpdateIfChanged, goCodeHash) {
		if err = h.writer(targetFileName, formattedGoCode); err != nil {
			return result, nil, fmt.Errorf("failed to write target file %q: %w", targetFileName, err)
		}
	}

	// Add the txt file if it has changed.
	if h.devMode {
		txtFileName := runtime.GetDevModeTextFileName(fileName)
		h.Log.Debug("Writing development mode text file", slog.String("file", fileName), slog.String("output", txtFileName))
		joined := strings.Join(generatorOutput.Literals, "\n")
		txtHash := sha256.Sum256([]byte(joined))
		if h.hashes.CompareAndSwap(txtFileName, syncmap.UpdateIfChanged, txtHash) {
			if err = os.WriteFile(txtFileName, []byte(joined), 0o644); err != nil {
				return result, nil, fmt.Errorf("failed to write string literal file %q: %w", txtFileName, err)
			}
		}
		// Check whether the change would require a recompilation or text update to take effect.
		previous, hasPrevious := h.fileNameToOutput.Get(fileName)
		if hasPrevious {
			result.TemplFileTextUpdated = generator.HasTextChanged(previous, generatorOutput)
			result.TemplFileGoUpdated = generator.HasGoChanged(previous, generatorOutput)
		}
		h.fileNameToOutput.Set(fileName, generatorOutput)
	}

	parsedDiagnostics, err := parser.Diagnose(t)
	if err != nil {
		return result, nil, fmt.Errorf("%s diagnostics error: %w", fileName, err)
	}

	if h.genSourceMapVis {
		err = generateSourceMapVisualisation(ctx, fileName, targetFileName, generatorOutput.SourceMap)
	}

	return result, parsedDiagnostics, err
}

// Takes an error from the formatter and attempts to convert the positions reported in the target file to their positions
// in the source file.
func remapErrorList(err error, sourceMap *parser.SourceMap, fileName string) error {
	list, ok := err.(scanner.ErrorList)
	if !ok || len(list) == 0 {
		return err
	}
	for i, e := range list {
		// The positions in the source map are off by one line because of the package definition.
		srcPos, ok := sourceMap.SourcePositionFromTarget(uint32(e.Pos.Line-1), uint32(e.Pos.Column))
		if !ok {
			continue
		}
		list[i].Pos = token.Position{
			Filename: fileName,
			Offset:   int(srcPos.Index),
			Line:     int(srcPos.Line) + 1,
			Column:   int(srcPos.Col),
		}
	}
	return list
}

func generateSourceMapVisualisation(ctx context.Context, templFileName, goFileName string, sourceMap *parser.SourceMap) error {
	if err := ctx.Err(); err != nil {
		return err
	}
	var templContents, goContents []byte
	var grp errgroup.Group
	grp.Go(func() (err error) {
		templContents, err = os.ReadFile(templFileName)
		return err
	})
	grp.Go(func() (err error) {
		goContents, err = os.ReadFile(goFileName)
		return err
	})
	if err := grp.Wait(); err != nil {
		return err
	}
	component := visualize.HTML(templFileName, string(templContents), string(goContents), sourceMap)

	targetFileName := strings.TrimSuffix(templFileName, ".templ") + "_templ_sourcemap.html"
	w, err := os.Create(targetFileName)
	if err != nil {
		return fmt.Errorf("%s sourcemap visualisation error: %w", templFileName, err)
	}
	b := bufio.NewWriter(w)
	if err = component.Render(ctx, b); err != nil {
		_ = w.Close()
		return fmt.Errorf("%s sourcemap visualisation render error: %w", templFileName, err)
	}
	if err = b.Flush(); err != nil {
		_ = w.Close()
		return fmt.Errorf("%s sourcemap visualisation flush error: %w", templFileName, err)
	}
	if err = w.Close(); err != nil {
		return fmt.Errorf("%s sourcemap visualisation close error: %w", templFileName, err)
	}
	return nil
}


================================================
FILE: cmd/templ/generatecmd/fatalerror.go
================================================
package generatecmd

type FatalError struct {
	Err error
}

func (e FatalError) Error() string {
	return e.Err.Error()
}

func (e FatalError) Unwrap() error {
	return e.Err
}

func (e FatalError) Is(target error) bool {
	_, ok := target.(FatalError)
	return ok
}

func (e FatalError) As(target any) bool {
	_, ok := target.(*FatalError)
	return ok
}


================================================
FILE: cmd/templ/generatecmd/main.go
================================================
package generatecmd

import (
	"context"
	_ "embed"
	"flag"
	"fmt"
	"io"
	"log/slog"
	"regexp"
	"runtime"

	_ "net/http/pprof"

	"github.com/a-h/templ/cmd/templ/sloghandler"
)

const generateUsageText = `usage: templ generate [<args>...]

Generates Go code from templ files.

Args:
  -path <path>
    Generates code for all files in path. (default .)
  -f <file>
    Optionally generates code for a single file, e.g. -f header.templ
  -stdout
    Prints to stdout instead of writing generated files to the filesystem.
    Only applicable when -f is used.
  -source-map-visualisations
    Set to true to generate HTML files to visualise the templ code and its corresponding Go code.
  -include-version
    Set to false to skip inclusion of the templ version in the generated code. (default true)
  -include-timestamp
    Set to true to include the current time in the generated code.
  -watch
    Set to true to watch the path for changes and regenerate code.
  -watch-pattern <regexp>
    Set the regexp pattern of files that will be watched for changes. (default: '(.+\.go$)|(.+\.templ$)|(.+_templ\.txt$)')
  -ignore-pattern <regexp>
    Set the regexp pattern of files to ignore when watching for changes. (default: '')
  -cmd <cmd>
    Set the command to run after generating code.
  -proxy
    Set the URL to proxy after generating code and executing the command.
  -proxyport
    The port the proxy will listen on. (default 7331)
  -proxybind
    The address the proxy will listen on. (default 127.0.0.1)
  -notify-proxy
    If present, the command will issue a reload event to the proxy 127.0.0.1:7331, or use proxyport and proxybind to specify a different address.
  -w
    Number of workers to use when generating code. (default runtime.NumCPUs)
  -lazy
    Only generate .go files if the source .templ file is newer.
  -pprof
    Port to run the pprof server on.
  -keep-orphaned-files
    Keeps orphaned generated templ files. (default false)
  -v
    Set log verbosity level to "debug". (default "info")
  -log-level
    Set log verbosity level. (default "info", options: "debug", "info", "warn", "error")
  -help
    Print help and exit.

Examples:

  Generate code for all files in the current directory and subdirectories:

    templ generate

  Generate code for a single file:

    templ generate -f header.templ

  Watch the current directory and subdirectories for changes and regenerate code:

    templ generate -watch
`

const defaultWatchPattern = `(.+\.go$)|(.+\.templ$)`

func NewArguments(stdout, stderr io.Writer, args []string) (cmdArgs Arguments, log *slog.Logger, help bool, err error) {
	cmd := flag.NewFlagSet("generate", flag.ContinueOnError)
	cmd.StringVar(&cmdArgs.FileName, "f", "", "")
	cmd.StringVar(&cmdArgs.Path, "path", ".", "")
	toStdoutFlag := cmd.Bool("stdout", false, "")
	cmd.BoolVar(&cmdArgs.GenerateSourceMapVisualisations, "source-map-visualisations", false, "")
	cmd.BoolVar(&cmdArgs.IncludeVersion, "include-version", true, "")
	cmd.BoolVar(&cmdArgs.IncludeTimestamp, "include-timestamp", false, "")
	cmd.BoolVar(&cmdArgs.Watch, "watch", false, "")
	watchPatternFlag := cmd.String("watch-pattern", defaultWatchPattern, "")
	ignorePatternFlag := cmd.String("ignore-pattern", "", "")
	cmd.BoolVar(&cmdArgs.OpenBrowser, "open-browser", true, "")
	cmd.StringVar(&cmdArgs.Command, "cmd", "", "")
	cmd.StringVar(&cmdArgs.Proxy, "proxy", "", "")
	cmd.IntVar(&cmdArgs.ProxyPort, "proxyport", 7331, "")
	cmd.StringVar(&cmdArgs.ProxyBind, "proxybind", "127.0.0.1", "")
	cmd.StringVar(&cmdArgs.ProxyTLSCrt, "proxy-tls-crt", "", "")
	cmd.StringVar(&cmdArgs.ProxyTLSKey, "proxy-tls-key", "", "")
	cmd.BoolVar(&cmdArgs.NotifyProxy, "notify-proxy", false, "")
	cmd.IntVar(&cmdArgs.WorkerCount, "w", runtime.NumCPU(), "")
	cmd.IntVar(&cmdArgs.PPROFPort, "pprof", 0, "")
	cmd.BoolVar(&cmdArgs.KeepOrphanedFiles, "keep-orphaned-files", false, "")
	cmd.BoolVar(&cmdArgs.Lazy, "lazy", false, "")
	verboseFlag := cmd.Bool("v", false, "")
	logLevelFlag := cmd.String("log-level", "info", "")
	helpFlag := cmd.Bool("help", false, "")
	if err = cmd.Parse(args); err != nil {
		return Arguments{}, nil, false, fmt.Errorf("failed to parse arguments: %w", err)
	}

	log = sloghandler.NewLogger(*logLevelFlag, *verboseFlag, stderr)

	if cmdArgs.Watch && cmdArgs.FileName != "" {
		return Arguments{}, log, *helpFlag, fmt.Errorf("cannot watch a single file, remove the -f or -watch flag")
	}
	cmdArgs.WatchPattern, err = regexp.Compile(*watchPatternFlag)
	if err != nil {
		return cmdArgs, log, *helpFlag, fmt.Errorf("invalid watch pattern %q: %w", *watchPatternFlag, err)
	}
	if *ignorePatternFlag != "" {
		cmdArgs.IgnorePattern, err = regexp.Compile(*ignorePatternFlag)
		if err != nil {
			return cmdArgs, log, *helpFlag, fmt.Errorf("invalid ignore pattern %q: %w", *ignorePatternFlag, err)
		}
	}

	// Default to writing to files unless the stdout flag is set.
	cmdArgs.FileWriter = FileWriter
	if *toStdoutFlag {
		if cmdArgs.FileName == "" {
			return Arguments{}, log, *helpFlag, fmt.Errorf("only a single file can be output to stdout, add the -f flag to specify the file to generate code for")
		}
		cmdArgs.FileWriter = WriterFileWriter(stdout)
	}

	// Validate TLS certificate flags.
	if (cmdArgs.ProxyTLSCrt == "") != (cmdArgs.ProxyTLSKey == "") {
		return Arguments{}, log, *helpFlag, fmt.Errorf("both -proxy-tls-crt and -proxy-tls-key must be provided together")
	}
	if cmdArgs.ProxyTLSCrt != "" && cmdArgs.Proxy == "" {
		return Arguments{}, log, *helpFlag, fmt.Errorf("-proxy-tls-crt and -proxy-tls-key can only be used with the -proxy flag")
	}

	return cmdArgs, log, *helpFlag, nil
}

type Arguments struct {
	FileName                        string
	FileWriter                      FileWriterFunc
	Path                            string
	Watch                           bool
	WatchPattern                    *regexp.Regexp
	IgnorePattern                   *regexp.Regexp
	OpenBrowser                     bool
	Command                         string
	ProxyBind                       string
	ProxyPort                       int
	Proxy                           string
	ProxyTLSCrt                     string
	ProxyTLSKey                     string
	NotifyProxy                     bool
	WorkerCount                     int
	GenerateSourceMapVisualisations bool
	IncludeVersion                  bool
	IncludeTimestamp                bool
	// PPROFPort is the port to run the pprof server on.
	PPROFPort         int
	KeepOrphanedFiles bool
	Lazy              bool
}

type ArgumentError struct {
	Message string
}

func (e *ArgumentError) Error() string {
	return e.Message
}

func (a *ArgumentError) Code() int {
	return 64 // EX_USAGE
}

func Run(ctx context.Context, stdout, stderr io.Writer, args []string) (err error) {
	cmdArgs, log, help, err := NewArguments(stdout, stderr, args)
	if err != nil {
		_, _ = fmt.Fprint(stderr, generateUsageText)
		return &ArgumentError{
			Message: err.Error(),
		}
	}
	if help {
		_, _ = fmt.Fprint(stdout, generateUsageText)
		return nil
	}
	g, err := NewGenerate(log, cmdArgs)
	if err != nil {
		return err
	}
	return g.Run(ctx)
}


================================================
FILE: cmd/templ/generatecmd/main_test.go
================================================
package generatecmd

import (
	"bytes"
	"context"
	"io"
	"os"
	"path"
	"regexp"
	"strings"
	"testing"
	"time"

	"github.com/a-h/templ/cmd/templ/testproject"
	"github.com/a-h/templ/runtime"
	"golang.org/x/sync/errgroup"
)

func TestGenerate(t *testing.T) {
	t.Run("can print help", func(t *testing.T) {
		// templ generate -help
		stdout := &bytes.Buffer{}
		err := Run(context.Background(), stdout, io.Discard, []string{"-help"})
		if err != nil {
			t.Fatalf("failed to run generate command: %v", err)
		}
		if !strings.Contains(stdout.String(), "usage: templ generate") {
			t.Fatalf("expected help output, got: %s", stdout.String())
		}
	})
	t.Run("can generate a file in place", func(t *testing.T) {
		// templ generate -f templates.templ
		dir, err := testproject.Create("github.com/a-h/templ/cmd/templ/testproject")
		if err != nil {
			t.Fatalf("failed to create test project: %v", err)
		}
		defer func() {
			if err := os.RemoveAll(dir); err != nil {
				t.Errorf("failed to remove test project directory: %v", err)
			}
		}()

		// Delete the templates_templ.go file to ensure it is generated.
		err = os.Remove(path.Join(dir, "templates_templ.go"))
		if err != nil {
			t.Fatalf("failed to remove templates_templ.go: %v", err)
		}

		// Run the generate command.
		err = Run(context.Background(), io.Discard, io.Discard, []string{"-f", path.Join(dir, "templates.templ")})
		if err != nil {
			t.Fatalf("failed to run generate command: %v", err)
		}

		// Check the templates_templ.go file was created.
		_, err = os.Stat(path.Join(dir, "templates_templ.go"))
		if err != nil {
			t.Fatalf("templates_templ.go was not created: %v", err)
		}
	})
	t.Run("can generate a file in watch mode", func(t *testing.T) {
		// templ generate -f templates.templ
		dir, err := testproject.Create("github.com/a-h/templ/cmd/templ/testproject")
		if err != nil {
			t.Fatalf("failed to create test project: %v", err)
		}
		defer func() {
			if err := os.RemoveAll(dir); err != nil {
				t.Errorf("failed to remove test project directory: %v", err)
			}
		}()

		// Delete the templates_templ.go file to ensure it is generated.
		err = os.Remove(path.Join(dir, "templates_templ.go"))
		if err != nil {
			t.Fatalf("failed to remove templates_templ.go: %v", err)
		}
		ctx, cancel := context.WithCancel(context.Background())

		var eg errgroup.Group
		eg.Go(func() error {
			return Run(ctx, io.Discard, io.Discard, []string{"-path", dir, "-watch"})
		})

		// Check the templates_templ.go file was created, with backoff.
		devModeTextFileName := runtime.GetDevModeTextFileName(path.Join(dir, "templates_templ.go"))
		for i := range 5 {
			time.Sleep(time.Second * time.Duration(i))
			_, err = os.Stat(path.Join(dir, "templates_templ.go"))
			if err != nil {
				continue
			}
			_, err = os.Stat(devModeTextFileName)
			if err != nil {
				continue
			}
			break
		}
		if err != nil {
			t.Errorf("template files were not created: %v", err)
		}

		cancel()
		if err := eg.Wait(); err != nil {
			t.Errorf("generate command failed: %v", err)
		}

		// Check the templates_templ.txt file was removed.
		_, err = os.Stat(path.Join(dir, devModeTextFileName))
		if err == nil {
			t.Error("templates_templ.txt was not removed")
		}
	})
}

func TestDefaultWatchPattern(t *testing.T) {
	tests := []struct {
		name    string
		input   string
		matches bool
	}{
		{
			name:    "empty file names do not match",
			input:   "",
			matches: false,
		},
		{
			name:    "*_templ.txt is no longer matched, Windows",
			input:   `C:\Users\adrian\github.com\a-h\templ\cmd\templ\testproject\strings_templ.txt`,
			matches: false,
		},
		{
			name:    "*_templ.txt is no longer matched, Unix",
			input:   "/Users/adrian/github.com/a-h/templ/cmd/templ/testproject/strings_templ.txt",
			matches: false,
		},
		{
			name:    "*.templ files match, Windows",
			input:   `C:\Users\adrian\github.com\a-h\templ\cmd\templ\testproject\templates.templ`,
			matches: true,
		},
		{
			name:    "*.templ files match, Unix",
			input:   "/Users/adrian/github.com/a-h/templ/cmd/templ/testproject/templates.templ",
			matches: true,
		},
		{
			name:    "*_templ.go files match, Windows",
			input:   `C:\Users\adrian\github.com\a-h\templ\cmd\templ\testproject\templates_templ.go`,
			matches: true,
		},
		{
			name:    "*_templ.go files match, Unix",
			input:   "/Users/adrian/github.com/a-h/templ/cmd/templ/testproject/templates_templ.go",
			matches: true,
		},
		{
			name:    "*.go files match, Windows",
			input:   `C:\Users\adrian\github.com\a-h\templ\cmd\templ\testproject\templates.go`,
			matches: true,
		},
		{
			name:    "*.go files match, Unix",
			input:   "/Users/adrian/github.com/a-h/templ/cmd/templ/testproject/templates.go",
			matches: true,
		},
		{
			name:    "*.css files do not match",
			input:   "/Users/adrian/github.com/a-h/templ/cmd/templ/testproject/templates.css",
			matches: false,
		},
	}
	wpRegexp, err := regexp.Compile(defaultWatchPattern)
	if err != nil {
		t.Fatalf("failed to compile default watch pattern: %v", err)
	}
	for _, test := range tests {
		t.Run(test.name, func(t *testing.T) {
			t.Parallel()
			if wpRegexp.MatchString(test.input) != test.matches {
				t.Fatalf("expected match of %q to be %v", test.input, test.matches)
			}
		})
	}
}

func TestArgs(t *testing.T) {
	t.Run("Help is true if the help flag is set", func(t *testing.T) {
		_, _, help, err := NewArguments(io.Discard, io.Discard, []string{"-help"})
		if err != nil {
			t.Fatal(err)
		}
		if !help {
			t.Fatal("expected help to be true")
		}
	})
	t.Run("Help is false if the help flag is not set", func(t *testing.T) {
		_, _, help, err := NewArguments(io.Discard, io.Discard, []string{})
		if err != nil {
			t.Fatal(err)
		}
		if help {
			t.Fatal("expected help to be false")
		}
	})
	t.Run("The worker count is set to the number of CPUs if not specified", func(t *testing.T) {
		args, _, _, err := NewArguments(io.Discard, io.Discard, []string{})
		if err != nil {
			t.Fatal(err)
		}
		if args.WorkerCount == 0 {
			t.Fatal("expected worker count to be set to the number of CPUs")
		}
	})
	t.Run("If toStdout is true, the file name must be specified", func(t *testing.T) {
		_, _, _, err := NewArguments(io.Discard, io.Discard, []string{"-stdout"})
		if err == nil {
			t.Fatal("expected error when toStdout is true but no file name is specified")
		}
	})
	t.Run("If toStdout is true, and the file name is specified, it writes to stdout", func(t *testing.T) {
		args, _, _, err := NewArguments(io.Discard, io.Discard, []string{"-stdout", "-f", "output.templ"})
		if err != nil {
			t.Fatal(err)
		}
		if args.FileName != "output.templ" {
			t.Fatalf("expected file name to be 'output.templ', got '%s'", args.FileName)
		}
		if args.FileWriter == nil {
			t.Fatal("expected FileWriter to be set when toStdout is true")
		}
	})
	t.Run("If the watchPattern is empty, it defaults to the default pattern", func(t *testing.T) {
		args, _, _, err := NewArguments(io.Discard, io.Discard, []string{})
		if err != nil {
			t.Fatal(err)
		}
		if args.WatchPattern.String() != defaultWatchPattern {
			t.Fatalf("expected watch pattern to be %q, got %q", defaultWatchPattern, args.WatchPattern.String())
		}
	})
	t.Run("If the watchPattern is set, it is checked for validity", func(t *testing.T) {
		_, _, _, err := NewArguments(io.Discard, io.Discard, []string{"-watch-pattern", "invalid[pattern"})
		if err == nil {
			t.Fatal("expected error when watch pattern is invalid")
		}
	})
	t.Run("If the watch flag is set, watch is set to true", func(t *testing.T) {
		args, _, _, err := NewArguments(io.Discard, io.Discard, []string{"-watch"})
		if err != nil {
			t.Fatal(err)
		}
		if !args.Watch {
			t.Fatal("expected watch to be true when the watch flag is set")
		}
	})
	t.Run("If the watch flag is not set, watch is false", func(t *testing.T) {
		args, _, _, err := NewArguments(io.Discard, io.Discard, []string{})
		if err != nil {
			t.Fatal(err)
		}
		if args.Watch {
			t.Fatal("expected watch to be false when the watch flag is not set")
		}
	})
	t.Run("The cmd flag can be set to specify a command to run after generating", func(t *testing.T) {
		args, _, _, err := NewArguments(io.Discard, io.Discard, []string{"-cmd", "echo hello"})
		if err != nil {
			t.Fatal(err)
		}
		if args.Command != "echo hello" {
			t.Fatalf("expected command to be 'echo hello', got '%s'", args.Command)
		}
	})
}


================================================
FILE: cmd/templ/generatecmd/modcheck/modcheck.go
================================================
package modcheck

import (
	"fmt"
	"os"
	"path/filepath"

	"github.com/a-h/templ"
	"golang.org/x/mod/modfile"
	"golang.org/x/mod/semver"
)

// WalkUp the directory tree, starting at dir, until we find a directory containing
// a go.mod file.
func WalkUp(dir string) (string, error) {
	dir, err := filepath.Abs(dir)
	if err != nil {
		return "", fmt.Errorf("failed to get absolute path: %w", err)
	}

	var modFile string
	for {
		modFile = filepath.Join(dir, "go.mod")
		_, err := os.Stat(modFile)
		if err != nil && !os.IsNotExist(err) {
			return "", fmt.Errorf("failed to stat go.mod file: %w", err)
		}
		if os.IsNotExist(err) {
			// Move up.
			prev := dir
			dir = filepath.Dir(dir)
			if dir == prev {
				break
			}
			continue
		}
		break
	}

	// No file found.
	if modFile == "" {
		return dir, fmt.Errorf("could not find go.mod file")
	}
	return dir, nil
}

func Check(dir string) error {
	dir, err := WalkUp(dir)
	if err != nil {
		return err
	}

	// Found a go.mod file.
	// Read it and find the templ version.
	modFile := filepath.Join(dir, "go.mod")
	m, err := os.ReadFile(modFile)
	if err != nil {
		return fmt.Errorf("failed to read go.mod file: %w", err)
	}

	mf, err := modfile.Parse(modFile, m, nil)
	if err != nil {
		return fmt.Errorf("failed to parse go.mod file: %w", err)
	}
	if mf.Module.Mod.Path == "github.com/a-h/templ" {
		// The go.mod file is for templ itself.
		return nil
	}
	for _, r := range mf.Require {
		if r.Mod.Path == "github.com/a-h/templ" {
			cmp := semver.Compare(r.Mod.Version, templ.Version())
			if cmp < 0 {
				return fmt.Errorf("generator %v is newer than templ version %v found in go.mod file, consider running `go get -u github.com/a-h/templ` to upgrade", templ.Version(), r.Mod.Version)
			}
			if cmp > 0 {
				return fmt.Errorf("generator %v is older than templ version %v found in go.mod file, consider upgrading templ CLI", templ.Version(), r.Mod.Version)
			}
			return nil
		}
	}
	return fmt.Errorf("templ not found in go.mod file, run `go get github.com/a-h/templ` to install it")
}


================================================
FILE: cmd/templ/generatecmd/modcheck/modcheck_test.go
================================================
package modcheck

import (
	"testing"

	"golang.org/x/mod/modfile"
)

func TestPatchGoVersion(t *testing.T) {
	tests := []struct {
		input    string
		expected string
	}{
		{
			input:    "go 1.20",
			expected: "1.20",
		},
		{
			input:    "go 1.20.123",
			expected: "1.20.123",
		},
		{
			input:    "go 1.20.1",
			expected: "1.20.1",
		},
		{
			input:    "go 1.20rc1",
			expected: "1.20rc1",
		},
		{
			input:    "go 1.15",
			expected: "1.15",
		},
	}
	for _, test := range tests {
		t.Run(test.input, func(t *testing.T) {
			input := "module github.com/a-h/templ\n\n" + string(test.input) + "\n" + "toolchain go1.27.9\n"
			mf, err := modfile.Parse("go.mod", []byte(input), nil)
			if err != nil {
				t.Fatalf("failed to parse go.mod: %v", err)
			}
			if test.expected != mf.Go.Version {
				t.Errorf("expected %q, got %q", test.expected, mf.Go.Version)
			}
		})
	}
}


================================================
FILE: cmd/templ/generatecmd/proxy/proxy.go
================================================
package proxy

import (
	"bytes"
	"compress/gzip"
	"fmt"
	"io"
	stdlog "log"
	"log/slog"
	"math"
	"net/http"
	"net/http/httputil"
	"net/url"
	"os"
	"strconv"
	"strings"
	"time"

	"github.com/a-h/templ/cmd/templ/generatecmd/sse"
	"github.com/a-h/templ/internal/htmlfind"
	"github.com/andybalholm/brotli"
	"golang.org/x/net/html"

	_ "embed"
)

//go:embed script.js
var script string

type Handler struct {
	log    *slog.Logger
	URL    string
	Target *url.URL
	p      *httputil.ReverseProxy
	sse    *sse.Handler
}

func reloadScript(nonce string) *html.Node {
	script := &html.Node{
		Type: html.ElementNode,
		Data: "script",
		Attr: []html.Attribute{
			{Key: "src", Val: "/_templ/reload/script.js"},
		},
	}
	if nonce != "" {
		script.Attr = append(script.Attr, html.Attribute{Key: "nonce", Val: nonce})
	}
	return script
}

var ErrBodyNotFound = fmt.Errorf("body not found")

func insertScriptTagIntoBody(nonce, body string) (updated string, err error) {
	n, err := html.Parse(strings.NewReader(body))
	if err != nil {
		return body, err
	}
	bodyNodes := htmlfind.All(n, htmlfind.Element("body"))
	if len(bodyNodes) == 0 {
		return body, ErrBodyNotFound
	}
	bodyNodes[0].AppendChild(reloadScript(nonce))
	buf := new(bytes.Buffer)
	if err = html.Render(buf, n); err != nil {
		return body, err
	}
	return buf.String(), nil
}

func isStreaming(r *http.Response, log *slog.Logger) bool {
	if strings.Contains(strings.ToLower(r.Header.Get("Transfer-Encoding")), "chunked") {
		log.DebugContext(r.Request.Context(), "Response is streaming because transfer encoding is chunked")
		return true
	}
	// Some servers omit both TE and Content-Length, in Go that's -1.
	if r.Header.Get("Content-Length") == "" && r.ContentLength == -1 {
		log.DebugContext(r.Request.Context(), "Response is streaming because content length is unspecified")
		return true
	}
	return false
}

func streamInsertAfterBodyOpen(nonce string, r io.Reader, w io.Writer) error {
	z := html.NewTokenizer(r)
	inserted := false
	for {
		tt := z.Next()
		switch tt {
		case html.ErrorToken:
			if z.Err() == io.EOF {
				return nil
			}
			return z.Err()
		case html.StartTagToken:
			t := z.Token()
			_, err := w.Write([]byte(t.String()))
			if err != nil {
				return err
			}
			if t.Data == "body" && !inserted {
				inserted = true
				scriptNode := reloadScript(nonce)
				var buf bytes.Buffer
				if err := html.Render(&buf, scriptNode); err != nil {
					return err
				}
				_, err = w.Write(buf.Bytes())
				if err != nil {
					return err
				}
			}
		default:
			_, err := w.Write(z.Raw())
			if err != nil {
				return err
			}
		}
	}
}

type passthroughWriteCloser struct {
	io.Writer
}

func (pwc passthroughWriteCloser) Close() error {
	return nil
}

const unsupportedContentEncoding = "Unsupported content encoding, hot reload script not inserted."

func (h *Handler) modifyResponse(r *http.Response) error {
	log := h.log.With(slog.String("url", r.Request.URL.String()))
	if r.Header.Get("templ-skip-modify") == "true" {
		log.Debug("Skipping response modification because templ-skip-modify header is set")
		return nil
	}
	if contentType := r.Header.Get("Content-Type"); !strings.HasPrefix(contentType, "text/html") {
		log.Debug("Skipping response modification because content type is not text/html", slog.String("content-type", contentType))
		return nil
	}

	// Set up readers and writers.
	newReader := func(in io.Reader) (out io.Reader, err error) {
		return in, nil
	}
	newWriter := func(out io.Writer) io.WriteCloser {
		return passthroughWriteCloser{out}
	}
	switch r.Header.Get("Content-Encoding") {
	case "gzip":
		newReader = func(in io.Reader) (out io.Reader, err error) {
			return gzip.NewReader(in)
		}
		newWriter = func(out io.Writer) io.WriteCloser {
			return gzip.NewWriter(out)
		}
	case "br":
		newReader = func(in io.Reader) (out io.Reader, err error) {
			return brotli.NewReader(in), nil
		}
		newWriter = func(out io.Writer) io.WriteCloser {
			return brotli.NewWriter(out)
		}
	case "":
		log.Debug("No content encoding header found")
	default:
		log.Warn(unsupportedContentEncoding, slog.String("encoding", r.Header.Get("Content-Encoding")))
	}

	csp := r.Header.Get("Content-Security-Policy")
	nonce := parseNonce(csp)

	if isStreaming(r, log) {
		// Create a pipe and replace the body with the read end of the pipe.
		pr, pw := io.Pipe()
		originalBody := r.Body
		r.Body = pr

		// Start a goroutine to read from the original body, modify it, and write to the pipe.
		go func() {
			defer func() {
				_ = originalBody.Close()
			}()
			encr, err := newReader(originalBody)
			if err != nil {
				log.Debug("Failed to read streaming response", slog.Any("error", err))
				_ = pw.CloseWithError(err)
				return
			}
			enc := newWriter(pw)
			defer func() {
				_ = enc.Close()
			}()

			if err := streamInsertAfterBodyOpen(nonce, encr, enc); err != nil {
				log.Debug("Failed to modify streaming response", slog.Any("error", err))
				_ = pw.CloseWithError(err)
				return
			}
			_ = pw.Close()
		}()

		return nil
	}

	// Read the encoded body.
	encr, err := newReader(r.Body)
	if err != nil {
		return err
	}
	defer func() {
		_ = r.Body.Close()
	}()
	body, err := io.ReadAll(encr)
	if err != nil {
		return err
	}

	// Update it.
	updated, err := insertScriptTagIntoBody(nonce, string(body))
	if err != nil {
		log.Warn("Unable to insert reload script", slog.Any("error", err))
		updated = string(body)
	}
	if len(updated) == len(body) {
		log.Debug("Reload script not inserted")
	} else {
		log.Debug("Reload script inserted")
	}

	// Encode the response.
	var buf bytes.Buffer
	encw := newWriter(&buf)
	_, err = encw.Write([]byte(updated))
	if err != nil {
		return err
	}
	err = encw.Close()
	if err != nil {
		return err
	}

	// Update the response.
	r.Body = io.NopCloser(&buf)
	r.ContentLength = int64(buf.Len())
	r.Header.Set("Content-Length", strconv.Itoa(buf.Len()))
	return nil
}

func parseNonce(csp string) (nonce string) {
outer:
	for _, rawDirective := range strings.Split(csp, ";") {
		parts := strings.Fields(rawDirective)
		if len(parts) < 2 {
			continue
		}
		if parts[0] != "script-src" {
			continue
		}
		for _, source := range parts[1:] {
			source = strings.TrimPrefix(source, "'")
			source = strings.TrimSuffix(source, "'")
			if strings.HasPrefix(source, "nonce-") {
				nonce = source[6:]
				break outer
			}
		}
	}
	return nonce
}

func New(log *slog.Logger, scheme string, bind string, port int, target *url.URL) (h *Handler) {
	p := httputil.NewSingleHostReverseProxy(target)
	p.ErrorLog = stdlog.New(os.Stderr, "Proxy to target error: ", 0)
	p.Transport = &roundTripper{
		maxRetries:      20,
		initialDelay:    100 * time.Millisecond,
		backoffExponent: 1.5,
	}
	h = &Handler{
		log:    log,
		URL:    fmt.Sprintf("%s://%s:%d", scheme, bind, port),
		Target: target,
		p:      p,
		sse:    sse.New(),
	}
	p.ModifyResponse = h.modifyResponse
	return h
}

func (p *Handler) ServeHTTP(w http.ResponseWriter, r *http.Request) {
	if r.URL.Path == "/_templ/reload/script.js" {
		// Provides a script that reloads the page.
		w.Header().Add("Content-Type", "text/javascript")
		_, err := io.WriteString(w, script)
		if err != nil {
			fmt.Printf("failed to write script: %v\n", err)
		}
		return
	}
	if r.URL.Path == "/_templ/reload/events" {
		switch r.Method {
		case http.MethodGet:
			// Provides a list of messages including a reload message.
			p.sse.ServeHTTP(w, r)
			return
		case http.MethodPost:
			// Send a reload message to all connected clients.
			p.sse.Send("message", "reload")
			return
		}
		http.Error(w, "only GET or POST method allowed", http.StatusMethodNotAllowed)
		return
	}
	p.p.ServeHTTP(w, r)
}

func (p *Handler) SendSSE(eventType string, data string) {
	p.sse.Send(eventType, data)
}

type roundTripper struct {
	maxRetries      int
	initialDelay    time.Duration
	backoffExponent float64
}

func (rt *roundTripper) setShouldSkipResponseModificationHeader(r *http.Request, resp *http.Response) {
	// Instruct the modifyResponse function to skip modifying the response if the
	// HTTP request has come from htmx or Datastar.
	if r.Header.Get("HX-Request") != "true" && r.Header.Get("Datastar-Request") != "true" {
		return
	}
	resp.Header.Set("templ-skip-modify", "true")
}

func (rt *roundTripper) RoundTrip(r *http.Request) (*http.Response, error) {
	// Read and buffer the body.
	var bodyBytes []byte
	if r.Body != nil && r.Body != http.NoBody {
		var err error
		bodyBytes, err = io.ReadAll(r.Body)
		if err != nil {
			return nil, err
		}
		if err = r.Body.Close(); err != nil {
			return nil, fmt.Errorf("failed to close request body: %w", err)
		}
	}

	// Retry logic.
	var resp *http.Response
	var err error
	for retries := range rt.maxRetries {
		// Clone the request and set the body.
		req := r.Clone(r.Context())
		if bodyBytes != nil {
			req.Body = io.NopCloser(bytes.NewReader(bodyBytes))
		}

		// Execute the request.
		resp, err = http.DefaultTransport.RoundTrip(req)
		if err != nil || resp.StatusCode == http.StatusBadGateway {
			time.Sleep(rt.initialDelay * time.Duration(math.Pow(rt.backoffExponent, float64(retries))))
			continue
		}

		rt.setShouldSkipResponseModificationHeader(r, resp)

		return resp, nil
	}

	return nil, fmt.Errorf("max retries reached: %q", r.URL.String())
}

func NotifyProxy(host string, port int) error {
	urlStr := fmt.Sprintf("http://%s:%d/_templ/reload/events", host, port)
	req, err := http.NewRequest(http.MethodPost, urlStr, nil)
	if err != nil {
		return err
	}
	_, err = http.DefaultClient.Do(req)
	return err
}


================================================
FILE: cmd/templ/generatecmd/proxy/proxy_test.go
================================================
package proxy

import (
	"bufio"
	"bytes"
	"compress/gzip"
	"context"
	"fmt"
	"io"
	"log/slog"
	"net/http"
	"net/http/httptest"
	"net/url"
	"os"
	"strconv"
	"strings"
	"sync"
	"testing"
	"time"

	"github.com/andybalholm/brotli"
	"github.com/google/go-cmp/cmp"
	"golang.org/x/net/html"
)

func TestRoundTripper(t *testing.T) {
	tests := []struct {
		name         string
		headers      map[string]string
		expectedSkip string
	}{
		{
			name:         "htmx requests skip modification",
			headers:      map[string]string{"HX-Request": "true"},
			expectedSkip: "true",
		},
		{
			name:         "Datastar requests skip modification",
			headers:      map[string]string{"Datastar-Request": "true"},
			expectedSkip: "true",
		},
		{
			name:         "Non-htmx and Datastar requests do not skip modification",
			headers:      map[string]string{},
			expectedSkip: "",
		},
	}
	for _, tc := range tests {
		t.Run(tc.name, func(t *testing.T) {
			t.Parallel()
			rt := &roundTripper{}
			req := httptest.NewRequest("GET", "http://example.com", nil)
			for k, v := range tc.headers {
				req.Header.Set(k, v)
			}
			resp := &http.Response{Header: make(http.Header)}
			rt.setShouldSkipResponseModificationHeader(req, resp)
			if resp.Header.Get("templ-skip-modify") != tc.expectedSkip {
				t.Errorf("expected templ-skip-modify header to be %q, got %q", tc.expectedSkip, resp.Header.Get("templ-skip-modify"))
			}
		})
	}
}

func getScriptTag(t *testing.T, nonce string) string {
	script := reloadScript(nonce)
	var buf bytes.Buffer
	err := html.Render(&buf, script)
	if err != nil {
		t.Fatalf("unexpected error rendering script tag: %v", err)
	}
	return buf.String()
}

func TestProxy(t *testing.T) {
	t.Run("plain: non-html content is not modified", func(t *testing.T) {
		// Arrange
		r := &http.Response{
			Body:   io.NopCloser(strings.NewReader(`{"key": "value"}`)),
			Header: make(http.Header),
			Request: &http.Request{
				URL: &url.URL{
					Scheme: "http",
					Host:   "example.com",
				},
			},
		}
		r.Header.Set("Content-Type", "application/json")
		r.Header.Set("Content-Length", "16")

		// Act
		log := slog.New(slog.NewJSONHandler(io.Discard, nil))
		h := New(log, "http", "127.0.0.1", 7474, &url.URL{Scheme: "http", Host: "example.com"})
		err := h.modifyResponse(r)
		if err != nil {
			t.Fatalf("unexpected error: %v", err)
		}

		// Assert
		if r.Header.Get("Content-Length") != "16" {
			t.Errorf("expected content length to be 16, got %v", r.Header.Get("Content-Length"))
		}
		actualBody, err := io.ReadAll(r.Body)
		if err != nil {
			t.Fatalf("unexpected error reading response: %v", err)
		}
		if diff := cmp.Diff(`{"key": "value"}`, string(actualBody)); diff != "" {
			t.Errorf("unexpected response body (-got +want):\n%s", diff)
		}
	})
	t.Run("plain: if the response contains templ-skip-modify header, it is not modified", func(t *testing.T) {
		// Arrange
		r := &http.Response{
			Body:   io.NopCloser(strings.NewReader(`Hello`)),
			Header: make(http.Header),
			Request: &http.Request{
				URL: &url.URL{
					Scheme: "http",
					Host:   "example.com",
				},
			},
		}
		r.Header.Set("Content-Type", "text/html")
		r.Header.Set("Content-Length", "5")
		r.Header.Set("templ-skip-modify", "true")

		// Act
		log := slog.New(slog.NewJSONHandler(io.Discard, nil))
		h := New(log, "http", "127.0.0.1", 7474, &url.URL{Scheme: "http", Host: "example.com"})
		err := h.modifyResponse(r)
		if err != nil {
			t.Fatalf("unexpected error: %v", err)
		}

		// Assert
		if r.Header.Get("Content-Length") != "5" {
			t.Errorf("expected content length to be 5, got %v", r.Header.Get("Content-Length"))
		}
		actualBody, err := io.ReadAll(r.Body)
		if err != nil {
			t.Fatalf("unexpected error reading response: %v", err)
		}
		if diff := cmp.Diff(`Hello`, string(actualBody)); diff != "" {
			t.Errorf("unexpected response body (-got +want):\n%s", diff)
		}
	})
	t.Run("plain: body tags get the script inserted", func(t *testing.T) {
		// Arrange
		r := &http.Response{
			Body:   io.NopCloser(strings.NewReader(`<html><body></body></html>`)),
			Header: make(http.Header),
			Request: &http.Request{
				URL: &url.URL{
					Scheme: "http",
					Host:   "example.com",
				},
			},
		}
		r.Header.Set("Content-Type", "text/html, charset=utf-8")
		r.Header.Set("Content-Length", "26")

		expectedString, err := insertScriptTagIntoBody("", `<html><body></body></html>`)
		if err != nil {
			t.Fatalf("unexpected error inserting script: %v", err)
		}
		if !strings.Contains(expectedString, getScriptTag(t, "")) {
			t.Fatalf("expected the script tag to be inserted, but it wasn't: %q", expectedString)
		}

		// Act
		log := slog.New(slog.NewJSONHandler(io.Discard, nil))
		h := New(log, "http", "127.0.0.1", 7474, &url.URL{Scheme: "http", Host: "example.com"})
		if err = h.modifyResponse(r); err != nil {
			t.Fatalf("unexpected error: %v", err)
		}

		// Assert
		if r.Header.Get("Content-Length") != fmt.Sprintf("%d", len(expectedString)) {
			t.Errorf("expected content length to be %d, got %v", len(expectedString), r.Header.Get("Content-Length"))
		}
		actualBody, err := io.ReadAll(r.Body)
		if err != nil {
			t.Fatalf("unexpected error reading response: %v", err)
		}
		if diff := cmp.Diff(expectedString, string(actualBody)); diff != "" {
			t.Errorf("unexpected response body (-got +want):\n%s", diff)
		}
	})
	t.Run("plain: body tags get the script inserted with nonce", func(t *testing.T) {
		// Arrange
		r := &http.Response{
			Body:   io.NopCloser(strings.NewReader(`<html><body></body></html>`)),
			Header: make(http.Header),
			Request: &http.Request{
				URL: &url.URL{
					Scheme: "http",
					Host:   "example.com",
				},
			},
		}
		r.Header.Set("Content-Type", "text/html, charset=utf-8")
		r.Header.Set("Content-Length", "26")
		const nonce = "this-is-the-nonce"
		r.Header.Set("Content-Security-Policy", fmt.Sprintf("script-src 'nonce-%s'", nonce))

		expectedString, err := insertScriptTagIntoBody(nonce, `<html><body></body></html>`)
		if err != nil {
			t.Fatalf("unexpected error inserting script: %v", err)
		}
		if !strings.Contains(expectedString, getScriptTag(t, nonce)) {
			t.Fatalf("expected the script tag to be inserted, but it wasn't: %q", expectedString)
		}

		// Act
		log := slog.New(slog.NewJSONHandler(io.Discard, nil))
		h := New(log, "http", "127.0.0.1", 7474, &url.URL{Scheme: "http", Host: "example.com"})
		if err = h.modifyResponse(r); err != nil {
			t.Fatalf("unexpected error: %v", err)
		}

		// Assert
		if r.Header.Get("Content-Length") != fmt.Sprintf("%d", len(expectedString)) {
			t.Errorf("expected content length to be %d, got %v", len(expectedString), r.Header.Get("Content-Length"))
		}
		actualBody, err := io.ReadAll(r.Body)
		if err != nil {
			t.Fatalf("unexpected error reading response: %v", err)
		}
		if diff := cmp.Diff(expectedString, string(actualBody)); diff != "" {
			t.Errorf("unexpected response body (-got +want):\n%s", diff)
		}
	})
	t.Run("plain: body tags get the script inserted ignoring js with body tags", func(t *testing.T) {
		// Arrange
		r := &http.Response{
			Body:   io.NopCloser(strings.NewReader(`<html><body><script>console.log("<body></body>")</script></body></html>`)),
			Header: make(http.Header),
			Request: &http.Request{
				URL: &url.URL{
					Scheme: "http",
					Host:   "example.com",
				},
			},
		}
		r.Header.Set("Content-Type", "text/html, charset=utf-8")
		r.Header.Set("Content-Length", "26")

		expectedString, err := insertScriptTagIntoBody("", `<html><body><script>console.log("<body></body>")</script></body></html>`)
		if err != nil {
			t.Fatalf("unexpected error inserting script: %v", err)
		}
		if !strings.Contains(expectedString, getScriptTag(t, "")) {
			t.Fatalf("expected the script tag to be inserted, but it wasn't: %q", expectedString)
		}
		if !strings.Contains(expectedString, `console.log("<body></body>")`) {
			t.Fatalf("expected the script tag to be inserted, but mangled the html: %q", expectedString)
		}

		// Act
		log := slog.New(slog.NewJSONHandler(io.Discard, nil))
		h := New(log, "http", "127.0.0.1", 7474, &url.URL{Scheme: "http", Host: "example.com"})
		if err = h.modifyResponse(r); err != nil {
			t.Fatalf("unexpected error: %v", err)
		}

		// Assert
		if r.Header.Get("Content-Length") != fmt.Sprintf("%d", len(expectedString)) {
			t.Errorf("expected content length to be %d, got %v", len(expectedString), r.Header.Get("Content-Length"))
		}
		actualBody, err := io.ReadAll(r.Body)
		if err != nil {
			t.Fatalf("unexpected error reading response: %v", err)
		}
		if diff := cmp.Diff(expectedString, string(actualBody)); diff != "" {
			t.Errorf("unexpected response body (-got +want):\n%s", diff)
		}
	})
	t.Run("gzip: non-html content is not modified", func(t *testing.T) {
		// Arrange
		r := &http.Response{
			Body:   io.NopCloser(strings.NewReader(`{"key": "value"}`)),
			Header: make(http.Header),
			Request: &http.Request{
				URL: &url.URL{
					Scheme: "http",
					Host:   "example.com",
				},
			},
		}
		r.Header.Set("Content-Type", "application/json")
		// It's not actually gzipped here, but it doesn't matter, it shouldn't get that far.
		r.Header.Set("Content-Encoding", "gzip")
		// Similarly, this is not the actual length of the gzipped content.
		r.Header.Set("Content-Length", "16")

		// Act
		log := slog.New(slog.NewJSONHandler(io.Discard, nil))
		h := New(log, "http", "127.0.0.1", 7474, &url.URL{Scheme: "http", Host: "example.com"})
		err := h.modifyResponse(r)
		if err != nil {
			t.Fatalf("unexpected error: %v", err)
		}

		// Assert
		if r.Header.Get("Content-Length") != "16" {
			t.Errorf("expected content length to be 16, got %v", r.Header.Get("Content-Length"))
		}
		actualBody, err := io.ReadAll(r.Body)
		if err != nil {
			t.Fatalf("unexpected error reading response: %v", err)
		}
		if diff := cmp.Diff(`{"key": "value"}`, string(actualBody)); diff != "" {
			t.Errorf("unexpected response body (-got +want):\n%s", diff)
		}
	})
	t.Run("gzip: body tags get the script inserted", func(t *testing.T) {
		// Arrange
		body := `<html><body></body></html>`
		var buf bytes.Buffer
		gzw := gzip.NewWriter(&buf)
		_, err := gzw.Write([]byte(body))
		if err != nil {
			t.Fatalf("unexpected error writing gzip: %v", err)
		}
		if err = gzw.Close(); err != nil {
			t.Fatalf("unexpected error closing gzip writer: %v", err)
		}

		expectedString, err := insertScriptTagIntoBody("", body)
		if err != nil {
			t.Fatalf("unexpected error inserting script: %v", err)
		}

		var expectedBytes bytes.Buffer
		gzw = gzip.NewWriter(&expectedBytes)
		_, err = gzw.Write([]byte(expectedString))
		if err != nil {
			t.Fatalf("unexpected error writing gzip: %v", err)
		}
		if err = gzw.Close(); err != nil {
			t.Fatalf("unexpected error closing gzip writer: %v", err)
		}
		expectedLength := len(expectedBytes.Bytes())

		r := &http.Response{
			Body:   io.NopCloser(&buf),
			Header: make(http.Header),
			Request: &http.Request{
				URL: &url.URL{
					Scheme: "http",
					Host:   "example.com",
				},
			},
		}
		r.Header.Set("Content-Type", "text/html, charset=utf-8")
		r.Header.Set("Content-Encoding", "gzip")
		r.Header.Set("Content-Length", fmt.Sprintf("%d", expectedLength))

		// Act
		log := slog.New(slog.NewJSONHandler(io.Discard, nil))
		h := New(log, "http", "127.0.0.1", 7474, &url.URL{Scheme: "http", Host: "example.com"})
		err = h.modifyResponse(r)
		if err != nil {
			t.Fatalf("unexpected error: %v", err)
		}

		// Assert
		if r.Header.Get("Content-Length") != fmt.Sprintf("%d", expectedLength) {
			t.Errorf("expected content length to be %d, got %v", expectedLength, r.Header.Get("Content-Length"))
		}

		gr, err := gzip.NewReader(r.Body)
		if err != nil {
			t.Fatalf("unexpected error reading response: %v", err)
		}
		actualBody, err := io.ReadAll(gr)
		if err != nil {
			t.Fatalf("unexpected error reading response: %v", err)
		}
		if diff := cmp.Diff(expectedString, string(actualBody)); diff != "" {
			t.Errorf("unexpected response body (-got +want):\n%s", diff)
		}
	})
	t.Run("brotli: body tags get the script inserted", func(t *testing.T) {
		// Arrange
		body := `<html><body></body></html>`
		var buf bytes.Buffer
		brw := brotli.NewWriter(&buf)
		_, err := brw.Write([]byte(body))
		if err != nil {
			t.Fatalf("unexpected error writing gzip: %v", err)
		}
		if err = brw.Close(); err != nil {
			t.Fatalf("unexpected error closing brotli writer: %v", err)
		}

		expectedString, err := insertScriptTagIntoBody("", body)
		if err != nil {
			t.Fatalf("unexpected error inserting script: %v", err)
		}

		var expectedBytes bytes.Buffer
		brw = brotli.NewWriter(&expectedBytes)
		_, err = brw.Write([]byte(expectedString))
		if err != nil {
			t.Fatalf("unexpected error writing gzip: %v", err)
		}
		if err = brw.Close(); err != nil {
			t.Fatalf("unexpected error closing brotli writer: %v", err)
		}
		expectedLength := len(expectedBytes.Bytes())

		r := &http.Response{
			Body:   io.NopCloser(&buf),
			Header: make(http.Header),
			Request: &http.Request{
				URL: &url.URL{
					Scheme: "http",
					Host:   "example.com",
				},
			},
		}
		r.Header.Set("Content-Type", "text/html, charset=utf-8")
		r.Header.Set("Content-Encoding", "br")
		r.Header.Set("Content-Length", fmt.Sprintf("%d", expectedLength))

		// Act
		log := slog.New(slog.NewJSONHandler(io.Discard, nil))
		h := New(log, "http", "127.0.0.1", 7474, &url.URL{Scheme: "http", Host: "example.com"})
		err = h.modifyResponse(r)
		if err != nil {
			t.Fatalf("unexpected error: %v", err)
		}

		// Assert
		if r.Header.Get("Content-Length") != fmt.Sprintf("%d", expectedLength) {
			t.Errorf("expected content length to be %d, got %v", expectedLength, r.Header.Get("Content-Length"))
		}

		actualBody, err := io.ReadAll(brotli.NewReader(r.Body))
		if err != nil {
			t.Fatalf("unexpected error reading response: %v", err)
		}
		if diff := cmp.Diff(expectedString, string(actualBody)); diff != "" {
			t.Errorf("unexpected response body (-got +want):\n%s", diff)
		}
	})
	t.Run("stream: body tags get the script inserted", func(t *testing.T) {
		// Arrange
		reqReader, reqWriter := io.Pipe()
		r := &http.Response{
			Body:   reqReader,
			Header: make(http.Header),
			Request: &http.Request{
				URL: &url.URL{
					Scheme: "http",
					Host:   "example.com",
				},
			},
		}
		r.Header.Set("Content-Type", "text/html; charset=utf-8")
		r.Header.Set("Transfer-Encoding", "chunked")

		expectedString, err := insertScriptTagIntoBody("", `<html><head></head><body></body></html>`)
		if err != nil {
			t.Fatalf("unexpected error inserting script: %v", err)
		}
		if !strings.Contains(expectedString, getScriptTag(t, "")) {
			t.Fatalf("expected the script tag to be inserted, but it wasn't: %q", expectedString)
		}

		// Act
		log := slog.New(slog.NewJSONHandler(os.Stdout, nil))
		h := New(log, "http", "127.0.0.1", 7474, &url.URL{Scheme: "http", Host: "example.com"})
		if err := h.modifyResponse(r); err != nil {
			t.Fatalf("unexpected error: %v", err)
		}

		streamingGap := 100 * time.Millisecond
		var writerErr1, writerErr2, reqWriterErr error
		go func() {
			_, writerErr1 = io.WriteString(reqWriter, `<html><head></head><body>`)
			time.Sleep(streamingGap) // simulate streaming
			_, writerErr2 = io.WriteString(reqWriter, `</body></html>`)
			reqWriterErr = reqWriter.Close()
		}()

		// Assert
		if got := r.Header.Get("Content-Length"); got != "" {
			t.Errorf("expected Content-Length to be cleared for streaming, got %q", got)
		}

		// Read the response body as it comes in, and look for at least one gap of >streamingGap between tokens.
		lastTime := time.Now()
		largestGap := time.Duration(0)
		sBB := &strings.Builder{}
		z := html.NewTokenizer(r.Body)
	tokenLoop:
		for {
			tt := z.Next()
			if since := time.Since(lastTime); since > largestGap {
				largestGap = since
			}
			lastTime = time.Now()

			switch tt {
			case html.ErrorToken:
				if z.Err() == io.EOF {
					break tokenLoop
				}
				t.Error("unexpected error token:", z.Err())
			default:
				if _, err := sBB.Write([]byte(z.Token().String())); err != nil {
					t.Error("unexpected error writing token:", err)
				}
			}
		}
		if diff := cmp.Diff(expectedString, sBB.String()); diff != "" {
			t.Errorf("unexpected response body (-got +want):\n%s", diff)
		}
		if largestGap < streamingGap {
			t.Errorf("expected at least one gap of >%v between tokens, got largest gap of %v", streamingGap, largestGap)
		}

		if writerErr1 != nil {
			t.Errorf("unexpected error writing part 1 of response: %v", writerErr1)
		}
		if writerErr2 != nil {
			t.Errorf("unexpected error writing part 2 of response: %v", writerErr2)
		}
		if reqWriterErr != nil {
			t.Errorf("unexpected error closing request writer: %v", reqWriterErr)
		}
	})
	t.Run("notify-proxy: sending POST request to /_templ/reload/events should receive reload sse event", func(t *testing.T) {
		// Arrange 1: create a test proxy server.
		dummyHandler := func(w http.ResponseWriter, r *http.Request) {}
		dummyServer := httptest.NewServer(http.HandlerFunc(dummyHandler))
		defer dummyServer.Close()

		u, err := url.Parse(dummyServer.URL)
		if err != nil {
			t.Fatalf("unexpected error parsing URL: %v", err)
		}
		log := slog.New(slog.NewJSONHandler(io.Discard, nil))
		handler := New(log, "http", "0.0.0.0", 0, u)
		proxyServer := httptest.NewServer(handler)
		defer proxyServer.Close()

		u2, err := url.Parse(proxyServer.URL)
		if err != nil {
			t.Fatalf("unexpected error parsing URL: %v", err)
		}
		port, err := strconv.Atoi(u2.Port())
		if err != nil {
			t.Fatalf("unexpected error parsing port: %v", err)
		}

		// Arrange 2: start a goroutine to listen for sse events.
		ctx := context.Background()
		ctx, cancel := context.WithTimeout(ctx, 3*time.Second)
		defer cancel()

		errChan := make(chan error)
		sseRespCh := make(chan string)
		sseListening := make(chan bool) // Coordination channel that ensures the SSE listener is started before notifying the proxy.
		go func() {
			req, err := http.NewRequestWithContext(ctx, "GET", fmt.Sprintf("%s/_templ/reload/events", proxyServer.URL), nil)
			if err != nil {
				errChan <- err
				return
			}
			resp, err := http.DefaultClient.Do(req)
			if err != nil {
				errChan <- err
				return
			}
			defer func() {
				_ = resp.Body.Close()
			}()

			sseListening <- true
			lines := []string{}
			scanner := bufio.NewScanner(resp.Body)
			for scanner.Scan() {
				lines = append(lines, scanner.Text())
				if scanner.Text() == "data: reload" {
					sseRespCh <- strings.Join(lines, "\n")
					return
				}
			}
			err = scanner.Err()
			if err != nil {
				errChan <- err
				return
			}
		}()

		// Act: notify the proxy.
		select { // Either SSE is listening or an error occurred.
		case <-sseListening:
			err = NotifyProxy(u2.Hostname(), port)
			if err != nil {
				t.Fatalf("unexpected error notifying proxy: %v", err)
			}
		case err := <-errChan:
			if err == nil {
				t.Fatalf("unexpected sse response: %v", err)
			}
		}

		// Assert.
		select { // Either SSE has a expected response or an error or timeout occurred.
		case resp := <-sseRespCh:
			if !strings.Contains(resp, "event: message\ndata: reload") {
				t.Errorf("expected sse reload event to be received, got: %q", resp)
			}
		case err := <-errChan:
			if err == nil {
				t.Fatalf("unexpected sse response: %v", err)
			}
		case <-ctx.Done():
			t.Fatalf("timeout waiting for sse response")
		}
	})
	t.Run("unsupported encodings result in a warning", func(t *testing.T) {
		// Arrange
		r := &http.Response{
			Body:   io.NopCloser(bytes.NewReader([]byte("<p>Data</p>"))),
			Header: make(http.Header),
			Request: &http.Request{
				URL: &url.URL{
					Scheme: "http",
					Host:   "example.com",
				},
			},
		}
		r.Header.Set("Content-Type", "text/html, charset=utf-8")
		r.Header.Set("Content-Encoding", "weird-encoding")

		// Act
		lh := newTestLogHandler(slog.LevelInfo)
		log := slog.New(lh)
		h := New(log, "http", "127.0.0.1", 7474, &url.URL{Scheme: "http", Host: "example.com"})
		err := h.modifyResponse(r)
		if err != nil {
			t.Fatalf("unexpected error: %v", err)
		}

		// Assert
		if len(lh.records) != 1 {
			var sb strings.Builder
			for _, record := range lh.records {
				sb.WriteString(record.Message)
				sb.WriteString("\n")
			}
			t.Fatalf("expected 1 log entry, but got %d: \n%s", len(lh.records), sb.String())
		}
		record := lh.records[0]
		if record.Message != unsupportedContentEncoding {
			t.Errorf("expected warning message %q, got %q", unsupportedContentEncoding, record.Message)
		}
		if record.Level != slog.LevelWarn {
			t.Errorf("expected warning, got level %v", record.Level)
		}
	})
}

func newTestLogHandler(level slog.Level) *testLogHandler {
	return &testLogHandler{
		m:       new(sync.Mutex),
		records: nil,
		level:   level,
	}
}

type testLogHandler struct {
	m       *sync.Mutex
	records []slog.Record
	level   slog.Level
}

func (h *testLogHandler) Enabled(ctx context.Context, l slog.Level) bool {
	return l >= h.level
}

func (h *testLogHandler) Handle(ctx context.Context, r slog.Record) error {
	h.m.Lock()
	defer h.m.Unlock()
	if r.Level < h.level {
		return nil
	}
	h.records = append(h.records, r)
	return nil
}

func (h *testLogHandler) WithAttrs(attrs []slog.Attr) slog.Handler {
	return h
}

func (h *testLogHandler) WithGroup(name string) slog.Handler {
	return h
}

func TestParseNonce(t *testing.T) {
	for _, tc := range []struct {
		name     string
		csp      string
		expected string
	}{
		{
			name:     "empty csp",
			csp:      "",
			expected: "",
		},
		{
			name:     "simple csp",
			csp:      "script-src 'nonce-oLhVst3hTAcxI734qtB0J9Qc7W4qy09C'",
			expected: "oLhVst3hTAcxI734qtB0J9Qc7W4qy09C",
		},
		{
			name:     "simple csp without single quote",
			csp:      "script-src nonce-oLhVst3hTAcxI734qtB0J9Qc7W4qy09C",
			expected: "oLhVst3hTAcxI734qtB0J9Qc7W4qy09C",
		},
		{
			name:     "complete csp",
			csp:      "default-src 'self'; frame-ancestors 'self'; form-action 'self'; script-src 'strict-dynamic' 'nonce-4VOtk0Uo1l7pwtC';",
			expected: "4VOtk0Uo1l7pwtC",
		},
		{
			name:     "mdn example 1",
			csp:      "default-src 'self'",
			expected: "",
		},
		{
			name:     "mdn example 2",
			csp:      "default-src 'self' *.trusted.com",
			expected: "",
		},
		{
			name:     "mdn example 3",
			csp:      "default-src 'self'; img-src *; media-src media1.com media2.com; script-src userscripts.example.com",
			expected: "",
		},
		{
			name:     "mdn example 3 multiple sources",
			csp:      "default-src 'self'; img-src *; media-src media1.com media2.com; script-src userscripts.example.com foo.com 'strict-dynamic' 'nonce-4VOtk0Uo1l7pwtC'",
			expected: "4VOtk0Uo1l7pwtC",
		},
	} {
		t.Run(tc.name, func(t *testing.T) {
			nonce := parseNonce(tc.csp)
			if nonce != tc.expected {
				t.Errorf("expected nonce to be %s, but got %s", tc.expected, nonce)
			}
		})
	}
}

func TestStreamInsertAfterBodyOpen(t *testing.T) {
	t.Run("script tags with special characters are not escaped", func(t *testing.T) {
		input := `<html>
<head><title>Test</title></head>
<body>
<script>
var x = localStorage.getItem('test');
var y = true && false;
</script>
</body>
</html>`

		var output bytes.Buffer
		err := streamInsertAfterBodyOpen("", strings.NewReader(input), &output)
		if err != nil {
			t.Fatalf("unexpected error: %v", err)
		}

		result := output.String()

		if !strings.Contains(result, "localStorage.getItem('test')") {
			t.Errorf("expected single quotes to not be escaped, got: %s", result)
		}
		if strings.Contains(result, "&#39;") {
			t.Errorf("single quotes should not be escaped to &#39;, got: %s", result)
		}
		if !strings.Contains(result, "true && false") {
			t.Errorf("expected && to not be escaped, got: %s", result)
		}
		if strings.Contains(result, "&amp;&amp;") {
			t.Errorf("&& should not be escaped to &amp;&amp;, got: %s", result)
		}
	})

	t.Run("large HTML with script tags maintains character integrity", func(t *testing.T) {
		var inputBuilder strings.Builder
		inputBuilder.WriteString(`<html>
<head><title>Test</title></head>
<body>
<script>
var x = localStorage.getItem('test');
var y = true && false;
alert("test");
</script>`)
		for i := range 50 {
			inputBuilder.WriteString(fmt.Sprintf("<div>%d padding</div>\n", i))
		}
		inputBuilder.WriteString("</body></html>")
		input := inputBuilder.String()

		var output bytes.Buffer
		err := streamInsertAfterBodyOpen("", strings.NewReader(input), &output)
		if err != nil {
			t.Fatalf("unexpected error: %v", err)
		}

		result := output.String()

		if !strings.Contains(result, "localStorage.getItem('test')") {
			t.Errorf("expected single quotes to not be escaped in large document")
		}
		if strings.Contains(result, "&#39;") {
			t.Errorf("single quotes should not be escaped to &#39; in large document")
		}
		if !strings.Contains(result, "true && false") {
			t.Errorf("expected && to not be escaped in large document")
		}
		if strings.Contains(result, "&amp;&amp;") {
			t.Errorf("&& should not be escaped to &amp;&amp; in large document")
		}
		if !strings.Contains(result, `alert("test")`) {
			t.Errorf("expected double quotes to not be escaped in large document")
		}
	})

	t.Run("script with nonce attribute is inserted correctly", func(t *testing.T) {
		input := `<html><body><p>Content</p></body></html>`
		nonce := "test-nonce-123"

		var output bytes.Buffer
		err := streamInsertAfterBodyOpen(nonce, strings.NewReader(input), &output)
		if err != nil {
			t.Fatalf("unexpected error: %v", err)
		}

		result := output.String()

		if !strings.Contains(result, `nonce="`+nonce+`"`) {
			t.Errorf("expected nonce attribute to be present with value %s, got: %s", nonce, result)
		}
		if !strings.Contains(result, `src="/_templ/reload/script.js"`) {
			t.Errorf("expected script src to be present, got: %s", result)
		}
	})
}


================================================
FILE: cmd/templ/generatecmd/proxy/script.js
================================================
(function() {
  let templ_reloadSrc = window.templ_reloadSrc || new EventSource("/_templ/reload/events");
  templ_reloadSrc.onmessage = (event) => {
    if (event && event.data === "reload") {
      window.location.reload();
    }
  };
  window.templ_reloadSrc = templ_reloadSrc;
  window.onbeforeunload = () => window.templ_reloadSrc.close();
})();


================================================
FILE: cmd/templ/generatecmd/run/run_test.go
================================================
package run_test

import (
	"context"
	"embed"
	"io"
	"net/http"
	"os"
	"path/filepath"
	"syscall"
	"testing"
	"time"

	"github.com/a-h/templ/cmd/templ/generatecmd/run"
)

//go:embed testprogram/*
var testprogram embed.FS

func TestGoRun(t *testing.T) {
	if testing.Short() {
		t.Skip("Skipping test in short mode.")
	}

	// Copy testprogram to a temporary directory.
	dir, err := os.MkdirTemp("", "testprogram")
	if err != nil {
		t.Fatalf("failed to make test dir: %v", err)
	}
	files, err := testprogram.ReadDir("testprogram")
	if err != nil {
		t.Fatalf("failed to read embedded dir: %v", err)
	}
	for _, file := range files {
		srcFileName := "testprogram/" + file.Name()
		srcData, err := testprogram.ReadFile(srcFileName)
		if err != nil {
			t.Fatalf("failed to read src file %q: %v", srcFileName, err)
		}
		tgtFileName := filepath.Join(dir, file.Name())
		if err = os.WriteFile(tgtFileName, srcData, 0644); err != nil {
			t.Fatalf("failed to write tgt file %q: %v", tgtFileName, err)
		}
	}
	// Rename the go.mod.embed file to go.mod.
	if err := os.Rename(filepath.Join(dir, "go.mod.embed"), filepath.Join(dir, "go.mod")); err != nil {
		t.Fatalf("failed to rename go.mod.embed: %v", err)
	}

	tests := []struct {
		name string
		cmd  string
	}{
		{
			name: "Well behaved programs get shut down",
			cmd:  "go run .",
		},
		{
			name: "Badly behaved programs get shut down",
			cmd:  "go run . -badly-behaved",
		},
	}
	for _, tt := range tests {
		t.Run(tt.name, func(t *testing.T) {
			ctx := context.Background()
			cmd, err := run.Run(ctx, dir, tt.cmd)
			if err != nil {
				t.Fatalf("failed to run program: %v", err)
			}

			time.Sleep(1 * time.Second)

			pid := cmd.Process.Pid

			if err := run.KillAll(); err != nil {
				t.Fatalf("failed to kill all: %v", err)
			}

			// Check the parent process is no longer running.
			if err := cmd.Process.Signal(os.Signal(syscall.Signal(0))); err == nil {
				t.Fatalf("process %d is still running", pid)
			}
			// Check that the child was stopped.
			body, err := readResponse("http://localhost:7777")
			if err == nil {
				t.Fatalf("child process is still running: %s", body)
			}
		})
	}
}

func readResponse(url string) (body string, err error) {
	resp, err := http.Get(url)
	if err != nil {
		return body, err
	}
	b, err := io.ReadAll(resp.Body)
	if err != nil {
		_ = resp.Body.Close()
		return body, err
	}
	if err = resp.Body.Close(); err != nil {
		return body, err
	}
	return string(b), nil
}


================================================
FILE: cmd/templ/generatecmd/run/run_unix.go
================================================
//go:build unix

package run

import (
	"context"
	"errors"
	"fmt"
	"os"
	"os/exec"
	"strings"
	"sync"
	"syscall"
	"time"
)

var (
	m       = &sync.Mutex{}
	running = map[string]*exec.Cmd{}
)

func KillAll() (err error) {
	m.Lock()
	defer m.Unlock()
	var errs []error
	for _, cmd := range running {
		if err := kill(cmd); err != nil {
			errs = append(errs, fmt.Errorf("failed to kill process %d: %w", cmd.Process.Pid, err))
		}
	}
	running = map[string]*exec.Cmd{}
	return errors.Join(errs...)
}

func kill(cmd *exec.Cmd) (err error) {
	errs := make([]error, 4)
	errs[0] = ignoreExited(cmd.Process.Signal(syscall.SIGINT))
	errs[1] = ignoreExited(cmd.Process.Signal(syscall.SIGTERM))
	errs[2] = ignoreExited(cmd.Wait())
	errs[3] = ignoreExited(syscall.Kill(-cmd.Process.Pid, syscall.SIGKILL))
	return errors.Join(errs...)
}

func ignoreExited(err error) error {
	if errors.Is(err, syscall.ESRCH) {
		return nil
	}
	// Ignore *exec.ExitError
	if _, ok := err.(*exec.ExitError); ok {
		return nil
	}
	return err
}

func Run(ctx context.Context, workingDir string, input string) (cmd *exec.Cmd, err error) {
	m.Lock()
	defer m.Unlock()
	cmd, ok := running[input]
	if ok {
		if err := kill(cmd); err != nil {
			return cmd, fmt.Errorf("failed to kill process %d: %w", cmd.Process.Pid, err)
		}

		delete(running, input)
	}
	parts := strings.Fields(input)
	executable := parts[0]
	args := []string{}
	if len(parts) > 1 {
		args = append(args, parts[1:]...)
	}

	cmd = exec.CommandContext(ctx, executable, args...)
	// Wait for the process to finish gracefully before termination.
	cmd.WaitDelay = time.Second * 3
	cmd.Env = os.Environ()
	cmd.Dir = workingDir
	cmd.Stdin = os.Stdin
	cmd.Stdout = os.Stdout
	cmd.Stderr = os.Stderr
	cmd.SysProcAttr = &syscall.SysProcAttr{Setpgid: true}
	running[input] = cmd
	err = cmd.Start()
	return
}


================================================
FILE: cmd/templ/generatecmd/run/run_windows.go
================================================
//go:build windows

package run

import (
	"context"
	"os"
	"os/exec"
	"strconv"
	"strings"
	"sync"
)

var (
	m       = &sync.Mutex{}
	running = map[string]*exec.Cmd{}
)

func KillAll() (err error) {
	m.Lock()
	defer m.Unlock()
	for _, cmd := range running {
		kill := exec.Command("TASKKILL", "/T", "/F", "/PID", strconv.Itoa(cmd.Process.Pid))
		kill.Stderr = os.Stderr
		kill.Stdout = os.Stdout
		err := kill.Run()
		if err != nil {
			return err
		}
	}
	running = map[string]*exec.Cmd{}
	return
}

func Stop(cmd *exec.Cmd) (err error) {
	kill := exec.Command("TASKKILL", "/T", "/F", "/PID", strconv.Itoa(cmd.Process.Pid))
	kill.Stderr = os.Stderr
	kill.Stdout = os.Stdout
	return kill.Run()
}

func Run(ctx context.Context, workingDir string, input string) (cmd *exec.Cmd, err error) {
	m.Lock()
	defer m.Unlock()
	cmd, ok := running[input]
	if ok {
		kill := exec.Command("TASKKILL", "/T", "/F", "/PID", strconv.Itoa(cmd.Process.Pid))
		kill.Stderr = os.Stderr
		kill.Stdout = os.Stdout
		err := kill.Run()
		if err != nil {
			return cmd, err
		}
		delete(running, input)
	}
	parts := strings.Fields(input)
	executable := parts[0]
	args := []string{}
	if len(parts) > 1 {
		args = append(args, parts[1:]...)
	}

	cmd = exec.Command(executable, args...)
	cmd.Env = os.Environ()
	cmd.Dir = workingDir
	cmd.Stdin = os.Stdin
	cmd.Stdout = os.Stdout
	cmd.Stderr = os.Stderr
	running[input] = cmd
	err = cmd.Start()
	return
}


================================================
FILE: cmd/templ/generatecmd/run/testprogram/go.mod.embed
================================================
module testprogram

go 1.23


================================================
FILE: cmd/templ/generatecmd/run/testprogram/main.go
================================================
package main

import (
	"flag"
	"fmt"
	"net/http"
	"os"
	"os/signal"
	"syscall"
	"time"
)

// This is a test program. It is used only to test the behaviour of the run package.
// The run package is supposed to be able to run and stop programs. Those programs may start
// child processes, which should also be stopped when the parent program is stopped.

// For example, running `go run .` will compile an executable and run it.

// So, this program does nothing. It just waits for a signal to stop.

// In "Well behaved" mode, the program will stop when it receives a signal.
// In "Badly behaved" mode, the program will ignore the signal and continue running.

// The run package should be able to stop the program in both cases.

var badlyBehavedFlag = flag.Bool("badly-behaved", false, "If set, the program will ignore the stop signal and continue running.")

func main() {
	flag.Parse()

	mode := "Well behaved"
	if *badlyBehavedFlag {
		mode = "Badly behaved"
	}
	fmt.Printf("%s process %d started.\n", mode, os.Getpid())

	// Start a web server on a known port so that we can check that this process is
	// not running, when it's been started as a child process, and we don't know
	// its pid.
	go func() {
		http.HandleFunc("/", func(w http.ResponseWriter, r *http.Request) {
			_, _ = fmt.Fprintf(w, "%d", os.Getpid())
		})
		err := http.ListenAndServe("127.0.0.1:7777", nil)
		if err != nil {
			fmt.Printf("Error running web server: %v\n", err)
		}
	}()

	sigs := make(chan os.Signal, 1)
	if !*badlyBehavedFlag {
		signal.Notify(sigs, os.Interrupt, syscall.SIGTERM)
	}
	for {
		select {
		case <-sigs:
			fmt.Printf("Process %d received signal. Stopping.\n", os.Getpid())
			return
		case <-time.After(1 * time.Second):
			fmt.Printf("Process %d still running...\n", os.Getpid())
		}
	}
}


================================================
FILE: cmd/templ/generatecmd/sse/server.go
================================================
package sse

import (
	_ "embed"
	"fmt"
	"net/http"
	"sync"
	"sync/atomic"
	"time"
)

func New() *Handler {
	return &Handler{
		m:        new(sync.Mutex),
		requests: map[int64]chan event{},
	}
}

type Handler struct {
	m        *sync.Mutex
	counter  int64
	requests map[int64]chan event
}

type event struct {
	Type string
	Data string
}

// Send an event to all connected clients.
func (s *Handler) Send(eventType string, data string) {
	s.m.Lock()
	defer s.m.Unlock()
	for _, f := range s.requests {
		f := f
		go func(f chan event) {
			f <- event{
				Type: eventType,
				Data: data,
			}
		}(f)
	}
}

func (s *Handler) ServeHTTP(w http.ResponseWriter, r *http.Request) {
	w.Header().Set("Access-Control-Allow-Origin", "*")
	w.Header().Set("Access-Control-Allow-Headers", "Content-Type")
	w.Header().Set("Content-Type", "text/event-stream")
	w.Header().Set("Cache-Control", "no-cache")
	w.Header().Set("Connection", "keep-alive")

	id := atomic.AddInt64(&s.counter, 1)
	s.m.Lock()
	events := make(chan event)
	s.requests[id] = events
	s.m.Unlock()
	defer func() {
		s.m.Lock()
		defer s.m.Unlock()
		delete(s.requests, id)
		close(events)
	}()

	timer := time.NewTimer(0)
loop:
	for {
		select {
		case <-timer.C:
			if _, err := fmt.Fprintf(w, "event: message\ndata: ping\n\n"); err != nil {
				http.Error(w, err.Error(), http.StatusInternalServerError)
				return
			}
			timer.Reset(time.Second * 5)
		case e := <-events:
			if _, err := fmt.Fprintf(w, "event: %s\ndata: %s\n\n", e.Type, e.Data); err != nil {
				http.Error(w, err.Error(), http.StatusInternalServerError)
				return
			}
		case <-r.Context().Done():
			break loop
		}
		w.(http.Flusher).Flush()
	}
}


================================================
FILE: cmd/templ/generatecmd/symlink/symlink_test.go
================================================
package symlink

import (
	"context"
	"io"
	"os"
	"path"
	"testing"

	"github.com/a-h/templ/cmd/templ/generatecmd"
	"github.com/a-h/templ/cmd/templ/testproject"
)

func TestSymlink(t *testing.T) {
	t.Run("can generate if root is symlink", func(t *testing.T) {
		// templ generate -f templates.templ
		dir, err := testproject.Create("github.com/a-h/templ/cmd/templ/testproject")
		if err != nil {
			t.Fatalf("failed to create test project: %v", err)
		}
		defer func() {
			if err := os.RemoveAll(dir); err != nil {
				t.Errorf("failed to remove test project directory: %v", err)
			}
		}()

		symlinkPath := dir + "-symlink"
		err = os.Symlink(dir, symlinkPath)
		if err != nil {
			t.Fatalf("failed to create dir symlink: %v", err)
		}
		defer func() {
			if err = os.Remove(symlinkPath); err != nil {
				t.Errorf("failed to remove symlink directory: %v", err)
			}
		}()

		// Delete the templates_templ.go file to ensure it is generated.
		err = os.Remove(path.Join(symlinkPath, "templates_templ.go"))
		if err != nil {
			t.Fatalf("failed to remove templates_templ.go: %v", err)
		}

		// Run the generate command.
		err = generatecmd.Run(context.Background(), io.Discard, io.Discard, []string{"-path", symlinkPath})
		if err != nil {
			t.Fatalf("failed to run generate command: %v", err)
		}

		// Check the templates_templ.go file was created.
		_, err = os.Stat(path.Join(symlinkPath, "templates_templ.go"))
		if err != nil {
			t.Fatalf("templates_templ.go was not created: %v", err)
		}
	})
}


================================================
FILE: cmd/templ/generatecmd/test-eventhandler/eventhandler_test.go
================================================
package testeventhandler

import (
	"context"
	"errors"
	"fmt"
	"go/scanner"
	"go/token"
	"io"
	"log/slog"
	"os"
	"testing"

	"github.com/a-h/templ/cmd/templ/generatecmd"
	"github.com/a-h/templ/generator"
	"github.com/fsnotify/fsnotify"
	"github.com/google/go-cmp/cmp"
)

// extractErrorList unwraps errors until it finds a scanner.ErrorList
func extractErrorList(err error) (scanner.ErrorList, bool) {
	if err == nil {
		return nil, false
	}

	if list, ok := err.(scanner.ErrorList); ok {
		return list, true
	}

	return extractErrorList(errors.Unwrap(err))
}

func TestErrorLocationMapping(t *testing.T) {
	tests := []struct {
		name           string
		rawFileName    string
		errorPositions []token.Position
	}{
		{
			name:        "single error outputs location in srcFile",
			rawFileName: "single_error.templ.error",
			errorPositions: []token.Position{
				{Offset: 46, Line: 3, Column: 20},
			},
		},
		{
			name:        "multiple errors all output locations in srcFile",
			rawFileName: "multiple_errors.templ.error",
			errorPositions: []token.Position{
				{Offset: 41, Line: 3, Column: 15},
				{Offset: 101, Line: 7, Column: 22},
				{Offset: 126, Line: 10, Column: 1},
			},
		},
	}

	slog := slog.New(slog.NewTextHandler(io.Discard, &slog.HandlerOptions{}))
	var fw generatecmd.FileWriterFunc
	fseh := generatecmd.NewFSEventHandler(slog, ".", false, []generator.GenerateOpt{}, false, false, fw, false)

	for _, test := range tests {
		t.Run(test.name, func(t *testing.T) {
			// The raw files cannot end in .templ because they will cause the generator to fail. Instead,
			// we create a tmp file that ends in .templ only for the duration of the test.
			rawFile, err := os.Open(test.rawFileName)
			if err != nil {
				t.Fatalf("Failed to open file %s: %v", test.rawFileName, err)
			}
			defer func() {
				if err = rawFile.Close(); err != nil {
					t.Fatalf("Failed to close raw file %s: %v", test.rawFileName, err)
				}
			}()

			file, err := os.CreateTemp("", fmt.Sprintf("*%s.templ", test.rawFileName))
			if err != nil {
				t.Fatalf("Failed to create a tmp file at %s: %v", file.Name(), err)
			}
			tempFileName := file.Name()
			defer func() {
				_ = file.Close()
				if err := os.Remove(tempFileName); err != nil {
					t.Logf("Warning: Failed to remove tmp file %s: %v", tempFileName, err)
				}
			}()

			if _, err = io.Copy(file, rawFile); err != nil {
				t.Fatalf("Failed to copy contents from raw file %s to tmp %s: %v", test.rawFileName, tempFileName, err)
			}

			// Ensure file is synced to disk and file pointer is at the beginning
			if err = file.Sync(); err != nil {
				t.Fatalf("Failed to sync file: %v", err)
			}

			event := fsnotify.Event{Name: tempFileName, Op: fsnotify.Write}
			_, err = fseh.HandleEvent(context.Background(), event)
			if err == nil {
				t.Fatal("Expected an error but none was thrown")
			}

			list, ok := extractErrorList(err)
			if !ok {
				t.Fatal("Failed to extract ErrorList from error")
			}

			if len(list) != len(test.errorPositions) {
				t.Fatalf("Expected %d errors but got %d", len(test.errorPositions), len(list))
			}

			for i, err := range list {
				expected := test.errorPositions[i]
				expected.Filename = tempFileName

				if diff := cmp.Diff(expected, err.Pos); diff != "" {
					t.Errorf("Error position mismatch (-expected +actual):\n%s", diff)
				}
			}
		})
	}
}


================================================
FILE: cmd/templ/generatecmd/test-eventhandler/multiple_errors.templ.error
================================================
package testeventhandler

func invalid(a: string) string {
    return "foo"
}

templ multipleError(a: string) {
    <div/>
}
l


================================================
FILE: cmd/templ/generatecmd/test-eventhandler/single_error.templ.error
================================================
package testeventhandler

templ singleError(a: string) {
    <div/>
}


================================================
FILE: cmd/templ/generatecmd/testwatch/generate_test.go
================================================
package testwatch

import (
	"bufio"
	"bytes"
	"context"
	"embed"
	"errors"
	"fmt"
	"io"
	"net"
	"net/http"
	"os"
	"path/filepath"
	"strconv"
	"strings"
	"testing"
	"time"

	"github.com/a-h/templ/cmd/templ/generatecmd"
	"github.com/a-h/templ/cmd/templ/generatecmd/modcheck"
	"github.com/a-h/templ/internal/htmlfind"
	"golang.org/x/net/html"
	"golang.org/x/sync/errgroup"
)

//go:embed testdata/*
var testdata embed.FS

func createTestProject(moduleRoot string) (dir string, err error) {
	dir, err = os.MkdirTemp("", "templ_watch_test_*")
	if err != nil {
		return dir, fmt.Errorf("failed to make test dir: %w", err)
	}
	files, err := testdata.ReadDir("testdata")
	if err != nil {
		return dir, fmt.Errorf("failed to read embedded dir: %w", err)
	}
	for _, file := range files {
		src := filepath.Join("testdata", file.Name())
		data, err := testdata.ReadFile(src)
		if err != nil {
			return dir, fmt.Errorf("failed to read file: %w", err)
		}

		target := filepath.Join(dir, file.Name())
		if file.Name() == "go.mod.embed" {
			data = bytes.ReplaceAll(data, []byte("{moduleRoot}"), []byte(moduleRoot))
			target = filepath.Join(dir, "go.mod")
		}
		err = os.WriteFile(target, data, 0660)
		if err != nil {
			return dir, fmt.Errorf("failed to copy file: %w", err)
		}
	}
	return dir, nil
}

func replaceInFile(name, src, tgt string) error {
	data, err := os.ReadFile(name)
	if err != nil {
		return err
	}
	updated := strings.ReplaceAll(string(data), src, tgt)
	return os.WriteFile(name, []byte(updated), 0660)
}

func getPort() (port int, err error) {
	var a *net.TCPAddr
	a, err = net.ResolveTCPAddr("tcp", "localhost:0")
	if err != nil {
		return 0, fmt.Errorf("failed to resolve TCP address: %w", err)
	}
	l, err := net.ListenTCP("tcp", a)
	if err != nil {
		return 0, fmt.Errorf("failed to listen on TCP: %w", err)
	}
	return l.Addr().(*net.TCPAddr).Port, l.Close()
}

func getHTML(url string) (n *html.Node, err error) {
	resp, err := http.Get(url)
	if err != nil {
		return nil, fmt.Errorf("failed to get %q: %w", url, err)
	}
	defer func() {
		_ = resp.Body.Close()
	}()
	return html.Parse(resp.Body)
}

func TestCanAccessDirect(t *testing.T) {
	if testing.Short() {
		return
	}
	args, teardown, err := Setup(false)
	if err != nil {
		t.Fatalf("failed to setup test: %v", err)
	}
	defer teardown(t)

	// Assert.
	doc, err := getHTML(args.AppURL)
	if err != nil {
		t.Fatalf("failed to read HTML: %v", err)
	}
	countElements := htmlfind.All(doc, htmlfind.Element("div", htmlfind.Attr("data-testid", "count")))
	if len(countElements) != 1 {
		t.Fatalf("expected 1 count element, got %d", len(countElements))
	}
	countText := countElements[0].FirstChild.Data
	actualCount, err := strconv.Atoi(countText)
	if err != nil {
		t.Fatalf("got count %q instead of integer", countText)
	}
	if actualCount < 1 {
		t.Errorf("expected count >= 1, got %d", actualCount)
	}
}

func TestCanAccessViaProxy(t *testing.T) {
	if testing.Short() {
		return
	}
	args, teardown, err := Setup(false)
	if err != nil {
		t.Fatalf("failed to setup test: %v", err)
	}
	defer teardown(t)

	// Assert.
	doc, err := getHTML(args.ProxyURL)
	if err != nil {
		t.Fatalf("failed to read HTML: %v", err)
	}
	countElements := htmlfind.All(doc, htmlfind.Element("div", htmlfind.Attr("data-testid", "count")))
	if len(countElements) != 1 {
		t.Fatalf("expected 1 count element, got %d", len(countElements))
	}
	countText := countElements[0].FirstChild.Data
	actualCount, err := strconv.Atoi(countText)
	if err != nil {
		t.Fatalf("got count %q instead of integer", countText)
	}
	if actualCount < 1 {
		t.Errorf("expected count >= 1, got %d", actualCount)
	}
}

type Event struct {
	Type string
	Data string
}

func readSSE(ctx context.Context, url string, sse chan<- Event) (err error) {
	req, err := http.NewRequestWithContext(ctx, "GET", url, nil)
	if err != nil {
		return err
	}
	req.Header.Set("Cache-Control", "no-cache")
	req.Header.Set("Accept", "text/event-stream")
	req.Header.Set("Connection", "keep-alive")

	client := &http.Client{}
	resp, err := client.Do(req)
	if err != nil {
		return err
	}

	var e Event
	scanner := bufio.NewScanner(resp.Body)
	for scanner.Scan() {
		line := scanner.Text()
		if line == "" {
			sse <- e
			e = Event{}
			continue
		}
		if strings.HasPrefix(line, "event: ") {
			e.Type = line[len("event: "):]
		}
		if strings.HasPrefix(line, "data: ") {
			e.Data = line[len("data: "):]
		}
	}
	return scanner.Err()
}

func TestFileModificationsResultInSSEWithGzip(t *testing.T) {
	if testing.Short() {
		return
	}
	args, teardown, err := Setup(false)
	if err != nil {
		t.Fatalf("failed to setup test: %v", err)
	}
	defer teardown(t)

	// Start the SSE check.
	events := make(chan Event)
	var eventsErr error
	go func() {
		eventsErr = readSSE(context.Background(), fmt.Sprintf("%s/_templ/reload/events", args.ProxyURL), events)
	}()

	// Assert data is expected.
	doc, err := getHTML(args.ProxyURL)
	if err != nil {
		t.Fatalf("failed to read HTML: %v", err)
	}
	modified := htmlfind.All(doc, htmlfind.Element("div", htmlfind.Attr("data-testid", "modification")))
	if len(modified) != 1 {
		t.Fatalf("expected 1 modification element, got %d", len(modified))
	}
	if text := modified[0].FirstChild.Data; text != "Original" {
		t.Errorf("expected %q, got %q", "Original", text)
	}

	// Change file.
	templFile := filepath.Join(args.AppDir, "templates.templ")
	err = replaceInFile(templFile,
		`<div data-testid="modification">Original</div>`,
		`<div data-testid="modification">Updated</div>`)
	if err != nil {
		t.Errorf("failed to replace text in file: %v", err)
	}

	// Give the filesystem watcher a few seconds.
	var reloadCount int
loop:
	for {
		select {
		case event := <-events:
			if event.Data == "reload" {
				reloadCount++
				break loop
			}
		case <-time.After(time.Second * 5):
			break loop
		}
	}
	if reloadCount == 0 {
		t.Error("failed to receive SSE about update after 5 seconds")
	}

	// Check to see if there were any errors.
	if eventsErr != nil {
		t.Errorf("error reading events: %v", err)
	}

	// See results in browser immediately.
	doc, err = getHTML(args.ProxyURL)
	if err != nil {
		t.Fatalf("failed to read HTML: %v", err)
	}
	modified = htmlfind.All(doc, htmlfind.Element("div", htmlfind.Attr("data-testid", "modification")))
	if len(modified) != 1 {
		t.Fatalf("expected 1 modification element, got %d", len(modified))
	}
	if text := modified[0].FirstChild.Data; text != "Updated" {
		t.Errorf("expected %q, got %q", "Updated", text)
	}
}

func TestFileModificationsResultInSSE(t *testing.T) {
	if testing.Short() {
		return
	}
	args, teardown, err := Setup(false)
	if err != nil {
		t.Fatalf("failed to setup test: %v", err)
	}
	defer teardown(t)

	// Start the SSE check.
	events := make(chan Event)
	var eventsErr error
	go func() {
		eventsErr = readSSE(context.Background(), fmt.Sprintf("%s/_templ/reload/events", args.ProxyURL), events)
	}()

	// Assert data is expected.
	doc, err := getHTML(args.ProxyURL)
	if err != nil {
		t.Fatalf("failed to read HTML: %v", err)
	}
	modified := htmlfind.All(doc, htmlfind.Element("div", htmlfind.Attr("data-testid", "modification")))
	if len(modified) != 1 {
		t.Fatalf("expected 1 modification element, got %d", len(modified))
	}
	if text := modified[0].FirstChild.Data; text != "Original" {
		t.Errorf("expected %q, got %q", "Original", text)
	}

	// Change file.
	templFile := filepath.Join(args.AppDir, "templates.templ")
	err = replaceInFile(templFile,
		`<div data-testid="modification">Original</div>`,
		`<div data-testid="modification">Updated</div>`)
	if err != nil {
		t.Errorf("failed to replace text in file: %v", err)
	}

	// Give the filesystem watcher a few seconds.
	var reloadCount int
loop:
	for {
		select {
		case event := <-events:
			if event.Data == "reload" {
				reloadCount++
				break loop
			}
		case <-time.After(time.Second * 5):
			break loop
		}
	}
	if reloadCount == 0 {
		t.Error("failed to receive SSE about update after 5 seconds")
	}

	// Check to see if there were any errors.
	if eventsErr != nil {
		t.Errorf("error reading events: %v", err)
	}

	// See results in browser immediately.
	doc, err = getHTML(args.ProxyURL)
	if err != nil {
		t.Fatalf("failed to read HTML: %v", err)
	}
	modified = htmlfind.All(doc, htmlfind.Element("div", htmlfind.Attr("data-testid", "modification")))
	if len(modified) != 1 {
		t.Fatalf("expected 1 modification element, got %d", len(modified))
	}
	if text := modified[0].FirstChild.Data; text != "Updated" {
		t.Errorf("expected %q, got %q", "Updated", text)
	}
}

func NewTestArgs(modRoot, appDir string, appPort int, proxyBind string, proxyPort int) TestArgs {
	return TestArgs{
		ModRoot:   modRoot,
		AppDir:    appDir,
		AppPort:   appPort,
		AppURL:    fmt.Sprintf("http://localhost:%d", appPort),
		ProxyBind: proxyBind,
		ProxyPort: proxyPort,
		ProxyURL:  fmt.Sprintf("http://%s:%d", proxyBind, proxyPort),
	}
}

type TestArgs struct {
	ModRoot   string
	AppDir    string
	AppPort   int
	AppURL    string
	ProxyBind string
	ProxyPort int
	ProxyURL  string
}

func Setup(gzipEncoding bool) (args TestArgs, teardown func(t *testing.T), err error) {
	wd, err := os.Getwd()
	if err != nil {
		return args, teardown, fmt.Errorf("could not find working dir: %w", err)
	}
	moduleRoot, err := modcheck.WalkUp(wd)
	if err != nil {
		return args, teardown, fmt.Errorf("could not find local templ go.mod file: %v", err)
	}

	appDir, err := createTestProject(moduleRoot)
	if err != nil {
		return args, teardown, fmt.Errorf("failed to create test project: %v", err)
	}
	appPort, err := getPort()
	if err != nil {
		return args, teardown, fmt.Errorf("failed to get available port: %v", err)
	}
	proxyPort, err := getPort()
	if err != nil {
		return args, teardown, fmt.Errorf("failed to get available port: %v", err)
	}
	proxyBind := "localhost"

	args = NewTestArgs(moduleRoot, appDir, appPort, proxyBind, proxyPort)
	ctx, cancel := context.WithCancel(context.Background())

	var wg errgroup.Group
	wg.Go(func() error {
		command := fmt.Sprintf("go run . -port %d", args.AppPort)
		if gzipEncoding {
			command += " -gzip true"
		}
		return generatecmd.Run(ctx, io.Discard, io.Discard, []string{"-path", appDir, "-watch", "-proxybind", proxyBind, "-proxyport", strconv.Itoa(proxyPort), "-proxy", args.AppURL, "-open-browser=false", "-cmd", command})
	})

	// Wait for server to start.
	if err = waitForURL(args.AppURL); err != nil {
		cancel()
		cmdErr := wg.Wait()
		return args, teardown, fmt.Errorf("failed to start app server: %w", errors.Join(cmdErr, err))
	}
	if err = waitForURL(args.ProxyURL); err != nil {
		cancel()
		cmdErr := wg.Wait()
		return args, teardown, fmt.Errorf("failed to start proxy server: %w", errors.Join(cmdErr, err))
	}

	// Wait for exit.
	teardown = func(t *testing.T) {
		cancel()
		if cmdErr := wg.Wait(); cmdErr != nil {
			t.Errorf("failed to run generate cmd: %v", cmdErr)
		}
		if err = os.RemoveAll(appDir); err != nil {
			t.Fatalf("failed to remove test dir %q: %v", appDir, err)
		}
	}
	return args, teardown, err
}

func waitForURL(url string) (err error) {
	var tries int
	for {
		time.Sleep(time.Second)
		if tries > 20 {
			return err
		}
		tries++
		var resp *http.Response
		resp, err = http.Get(url)
		if err != nil {
			fmt.Printf("failed to get %q: %v\n", url, err)
			continue
		}
		if resp.StatusCode != http.StatusOK {
			fmt.Printf("failed to get %q: %v\n", url, err)
			err = fmt.Errorf("expected status code %d, got %d", http.StatusOK, resp.StatusCode)
			continue
		}
		return nil
	}
}

func TestGenerateReturnsErrors(t *testing.T) {
	wd, err := os.Getwd()
	if err != nil {
		t.Fatalf("could not find working dir: %v", err)
	}
	moduleRoot, err := modcheck.WalkUp(wd)
	if err != nil {
		t.Fatalf("could not find local templ go.mod file: %v", err)
	}

	appDir, err := createTestProject(moduleRoot)
	if err != nil {
		t.Fatalf("failed to create test project: %v", err)
	}
	defer func() {
		if err = os.RemoveAll(appDir); err != nil {
			t.Fatalf("failed to remove test dir %q: %v", appDir, err)
		}
	}()

	// Break the HTML.
	templFile := filepath.Join(appDir, "templates.templ")
	err = replaceInFile(templFile,
		`<div data-testid="modification">Original</div>`,
		`<div data-testid="modification" -unclosed div-</div>`)
	if err != nil {
		t.Errorf("failed to replace text in file: %v", err)
	}

	// Run.
	err = generatecmd.Run(context.Background(), io.Discard, io.Discard, []string{"-path", appDir, "-include-version=false", "-include-timestamp=false", "-keep-orphaned-files=false"})
	if err == nil {
		t.Errorf("expected generation error, got %v", err)
	}
}


================================================
FILE: cmd/templ/generatecmd/testwatch/testdata/go.mod.embed
================================================
module templ/testproject

go 1.25.0

require github.com/a-h/templ v0.3.847 // indirect

replace github.com/a-h/templ => {moduleRoot}


================================================
FILE: cmd/templ/generatecmd/testwatch/testdata/go.sum
================================================
github.com/a-h/templ v0.3.833 h1:L/KOk/0VvVTBegtE0fp2RJQiBm7/52Zxv5fqlEHiQUU=
github.com/a-h/templ v0.3.833/go.mod h1:cAu4AiZhtJfBjMY0HASlyzvkrtjnHWPeEsyGK2YYmfk=
github.com/google/go-cmp v0.6.0 h1:ofyhxvXcZhMsU5ulbFiLKl/XBFqE1GSq7atu8tAmTRI=
github.com/google/go-cmp v0.6.0/go.mod h1:17dUlkBOakJ0+DkrSSNjCkIjxS6bF9zb3elmeNGIjoY=


================================================
FILE: cmd/templ/generatecmd/testwatch/testdata/main.go
================================================
package main

import (
	"bytes"
	"compress/gzip"
	"flag"
	"fmt"
	"log/slog"
	"net/http"
	"os"
	"strconv"

	"github.com/a-h/templ"
)

type GzipResponseWriter struct {
	w http.ResponseWriter
}

func (w *GzipResponseWriter) Header() http.Header {
	return w.w.Header()
}

func (w *GzipResponseWriter) Write(b []byte) (int, error) {
	var buf bytes.Buffer
	gzw := gzip.NewWriter(&buf)
	defer gzw.Close()

	_, err := gzw.Write(b)
	if err != nil {
		return 0, err
	}
	err = gzw.Close()
	if err != nil {
		return 0, err
	}

	w.w.Header().Set("Content-Length", strconv.Itoa(buf.Len()))

	return w.w.Write(buf.Bytes())
}

func (w *GzipResponseWriter) WriteHeader(statusCode int) {
	w.w.WriteHeader(statusCode)
}

var flagPort = flag.Int("port", 0, "Set the HTTP listen port")
var useGzip = flag.Bool("gzip", false, "Toggle gzip encoding")

func main() {
	flag.Parse()

	if *flagPort == 0 {
		fmt.Println("missing port flag")
		os.Exit(1)
	}

	var count int
	http.HandleFunc("/", func(w http.ResponseWriter, r *http.Request) {
		if useGzip != nil && *useGzip {
			w.Header().Set("Content-Encoding", "gzip")
			w = &GzipResponseWriter{w: w}
		}

		count++
		c := Page(count)
		h := templ.Handler(c)
		h.ErrorHandler = func(r *http.Request, err error) http.Handler {
			slog.Error("failed to render template", slog.Any("error", err))
			return http.HandlerFunc(func(w http.ResponseWriter, r *http.Request) {
				http.Error(w, err.Error(), http.StatusInternalServerError)
			})
		}
		h.ServeHTTP(w, r)
	})
	err := http.ListenAndServe(fmt.Sprintf("localhost:%d", *flagPort), nil)
	if err != nil {
		fmt.Printf("Error listening: %v\n", err)
		os.Exit(1)
	}
}


================================================
FILE: cmd/templ/generatecmd/testwatch/testdata/templates.templ
================================================
package main

import "fmt"

templ Page(count int) {
	<!DOCTYPE html>
	<html>
		<head>
			<title>templ test page</title>
		</head>
		<body>
			<h1>Count</h1>
			<div data-testid="count">{ fmt.Sprintf("%d", count) }</div>
			<div data-testid="modification">Original</div>
		</body>
	</html>
}


================================================
FILE: cmd/templ/generatecmd/testwatch/testdata/templates_templ.go
================================================
// Code generated by templ - DO NOT EDIT.

package main

//lint:file-ignore SA4006 This context is only used if a nested component is present.

import "github.com/a-h/templ"
import templruntime "github.com/a-h/templ/runtime"

import "fmt"

func Page(count int) templ.Component {
	return templruntime.GeneratedTemplate(func(templ_7745c5c3_Input templruntime.GeneratedComponentInput) (templ_7745c5c3_Err error) {
		templ_7745c5c3_W, ctx := templ_7745c5c3_Input.Writer, templ_7745c5c3_Input.Context
		if templ_7745c5c3_CtxErr := ctx.Err(); templ_7745c5c3_CtxErr != nil {
			return templ_7745c5c3_CtxErr
		}
		templ_7745c5c3_Buffer, templ_7745c5c3_IsBuffer := templruntime.GetBuffer(templ_7745c5c3_W)
		if !templ_7745c5c3_IsBuffer {
			defer func() {
				templ_7745c5c3_BufErr := templruntime.ReleaseBuffer(templ_7745c5c3_Buffer)
				if templ_7745c5c3_Err == nil {
					templ_7745c5c3_Err = templ_7745c5c3_BufErr
				}
			}()
		}
		ctx = templ.InitializeContext(ctx)
		templ_7745c5c3_Var1 := templ.GetChildren(ctx)
		if templ_7745c5c3_Var1 == nil {
			templ_7745c5c3_Var1 = templ.NopComponent
		}
		ctx = templ.ClearChildren(ctx)
		templ_7745c5c3_Err = templruntime.WriteString(templ_7745c5c3_Buffer, 1, "<!doctype html><html><head><title>templ test page</title></head><body><h1>Count</h1><div data-testid=\"count\">")
		if templ_7745c5c3_Err != nil {
			return templ_7745c5c3_Err
		}
		var templ_7745c5c3_Var2 string
		templ_7745c5c3_Var2, templ_7745c5c3_Err = templ.JoinStringErrs(fmt.Sprintf("%d", count))
		if templ_7745c5c3_Err != nil {
			return templ.Error{Err: templ_7745c5c3_Err, FileName: `cmd/templ/generatecmd/testwatch/testdata/templates.templ`, Line: 13, Col: 54}
		}
		_, templ_7745c5c3_Err = templ_7745c5c3_Buffer.WriteString(templ.EscapeString(templ_7745c5c3_Var2))
		if templ_7745c5c3_Err != nil {
			return templ_7745c5c3_Err
		}
		templ_7745c5c3_Err = templruntime.WriteString(templ_7745c5c3_Buffer, 2, "</div><div data-testid=\"modification\">Original</div></body></html>")
		if templ_7745c5c3_Err != nil {
			return templ_7745c5c3_Err
		}
		return nil
	})
}

var _ = templruntime.GeneratedTemplate


================================================
FILE: cmd/templ/generatecmd/watcher/watch.go
================================================
package watcher

import (
	"context"
	"io/fs"
	"os"
	"path/filepath"
	"regexp"
	"sync"
	"time"

	"github.com/a-h/templ/internal/skipdir"
	"github.com/fsnotify/fsnotify"
)

func Recursive(
	ctx context.Context,
	watchPattern *regexp.Regexp,
	ignorePattern *regexp.Regexp,
	out chan fsnotify.Event,
	errors chan error,
) (w *RecursiveWatcher, err error) {
	fsnw, err := fsnotify.NewWatcher()
	if err != nil {
		return nil, err
	}
	w = &RecursiveWatcher{
		ctx:           ctx,
		w:             fsnw,
		WatchPattern:  watchPattern,
		IgnorePattern: ignorePattern,
		Events:        out,
		Errors:        errors,
		timers:        make(map[timerKey]*time.Timer),
		loopComplete:  sync.WaitGroup{},
	}
	w.loopComplete.Add(1)
	go func() {
		defer w.loopComplete.Done()
		w.loop()
	}()
	return w, nil
}

// WalkFiles walks the file tree rooted at path, sending a Create event for each
// file it encounters.
func WalkFiles(ctx context.Context, rootPath string, watchPattern, ignorePattern *regexp.Regexp, out chan fsnotify.Event) (err error) {
	return fs.WalkDir(os.DirFS(rootPath), ".", func(path string, info os.DirEntry, err error) error {
		if err != nil {
			return nil
		}
		absPath, err := filepath.Abs(filepath.Join(rootPath, path))
		if err != nil {
			return nil
		}
		if info.IsDir() && skipdir.ShouldSkip(absPath) {
			return filepath.SkipDir
		}
		if !watchPattern.MatchString(absPath) {
			return nil
		}
		if ignorePattern != nil && ignorePattern.MatchString(absPath) {
			return nil
		}
		out <- fsnotify.Event{
			Name: absPath,
			Op:   fsnotify.Create,
		}
		return nil
	})
}

type RecursiveWatcher struct {
	ctx           context.Context
	w             *fsnotify.Watcher
	WatchPattern  *regexp.Regexp
	IgnorePattern *regexp.Regexp
	Events        chan fsnotify.Event
	Errors        chan error
	timerMu       sync.Mutex
	timers        map[timerKey]*time.Timer
	loopComplete  sync.WaitGroup
}

type timerKey struct {
	name string
	op   fsnotify.Op
}

func timerKeyFromEvent(event fsnotify.Event) timerKey {
	return timerKey{
		name: event.Name,
		op:   event.Op,
	}
}

func (w *RecursiveWatcher) Close() error {
	w.loopComplete.Wait()
	for _, timer := range w.timers {
		timer.Stop()
	}
	return w.w.Close()
}

func (w *RecursiveWatcher) loop() {
	for {
		select {
		case <-w.ctx.Done():
			return
		case event, ok := <-w.w.Events:
			if !ok {
				return
			}
			if event.Has(fsnotify.Create) {
				if err := w.Add(event.Name); err != nil {
					w.Errors <- err
				}
			}
			// Only notify on templ related files.
			if !w.WatchPattern.MatchString(event.Name) {
				continue
			}
			// Skip files that match the ignore pattern.
			if w.IgnorePattern != nil && w.IgnorePattern.MatchString(event.Name) {
				continue
			}
			tk := timerKeyFromEvent(event)
			w.timerMu.Lock()
			t, ok := w.timers[tk]
			w.timerMu.Unlock()
			if !ok {
				t = time.AfterFunc(100*time.Millisecond, func() {
					if w.ctx.Err() != nil {
						return
					}
					w.Events <- event
				})
				w.timerMu.Lock()
				w.timers[tk] = t
				w.timerMu.Unlock()
				continue
			}
			t.Reset(100 * time.Millisecond)
		case err, ok := <-w.w.Errors:
			if !ok {
				return
			}
			w.Errors <- err
		}
	}
}

func (w *RecursiveWatcher) Add(dir string) error {
	return filepath.WalkDir(dir, func(dir string, info os.DirEntry, err error) error {
		if err != nil {
			return nil
		}
		if !info.IsDir() {
			return nil
		}
		if skipdir.ShouldSkip(dir) {
			return filepath.SkipDir
		}
		return w.w.Add(dir)
	})
}


================================================
FILE: cmd/templ/generatecmd/watcher/watch_test.go
================================================
package watcher

import (
	"context"
	"fmt"
	"regexp"
	"testing"
	"time"

	"github.com/fsnotify/fsnotify"
)

func TestWatchDebouncesDuplicates(t *testing.T) {
	ctx, cancel := context.WithCancel(context.Background())
	events := make(chan fsnotify.Event, 2)
	errors := make(chan error)
	watchPattern, err := regexp.Compile(".*")
	if err != nil {
		t.Fatal(fmt.Errorf("failed to compile watch pattern: %w", err))
	}
	rw, err := Recursive(ctx, watchPattern, nil, events, errors)
	if err != nil {
		t.Fatal(fmt.Errorf("failed to create recursive watcher: %w", err))
	}
	go func() {
		rw.w.Events <- fsnotify.Event{Name: "test.templ"}
		rw.w.Events <- fsnotify.Event{Name: "test.templ"}
	}()
	count := 0
	exp := time.After(300 * time.Millisecond)
	for {
		select {
		case <-rw.Events:
			count++
		case <-exp:
			if count != 1 {
				t.Errorf("expected 1 event, got %d", count)
			}
			cancel()
			if err := rw.Close(); err != nil {
				t.Errorf("unexpected error closing watcher: %v", err)
			}
			return
		}
	}
}

func TestWatchDoesNotDebounceDifferentEvents(t *testing.T) {
	tests := []struct {
		event1 fsnotify.Event
		event2 fsnotify.Event
	}{
		// Different files
		{fsnotify.Event{Name: "test.templ"}, fsnotify.Event{Name: "test2.templ"}},
		// Different operations
		{
			fsnotify.Event{Name: "test.templ", Op: fsnotify.Create},
			fsnotify.Event{Name: "test.templ", Op: fsnotify.Write},
		},
		// Different operations and files
		{
			fsnotify.Event{Name: "test.templ", Op: fsnotify.Create},
			fsnotify.Event{Name: "test2.templ", Op: fsnotify.Write},
		},
	}
	for _, test := range tests {
		ctx, cancel := context.WithCancel(context.Background())
		events := make(chan fsnotify.Event, 2)
		errors := make(chan error)
		watchPattern, err := regexp.Compile(".*")
		if err != nil {
			t.Fatal(fmt.Errorf("failed to compile watch pattern: %w", err))
		}
		rw, err := Recursive(ctx, watchPattern, nil, events, errors)
		if err != nil {
			t.Fatal(fmt.Errorf("failed to create recursive watcher: %w", err))
		}
		go func() {
			rw.w.Events <- test.event1
			rw.w.Events <- test.event2
		}()
		count := 0
		exp := time.After(300 * time.Millisecond)
		for {
			select {
			case <-rw.Events:
				count++
			case <-exp:
				if count != 2 {
					t.Errorf("expected 2 event, got %d", count)
				}
				cancel()
				if err := rw.Close(); err != nil {
					t.Errorf("unexpected error closing watcher: %v", err)
				}
				return
			}
		}
	}
}

func TestWatchDoesNotDebounceSeparateEvents(t *testing.T) {
	ctx, cancel := context.WithCancel(context.Background())
	events := make(chan fsnotify.Event, 2)
	errors := make(chan error)
	watchPattern, err := regexp.Compile(".*")
	if err != nil {
		t.Fatal(fmt.Errorf("failed to compile watch pattern: %w", err))
	}
	rw, err := Recursive(ctx, watchPattern, nil, events, errors)
	if err != nil {
		t.Fatal(fmt.Errorf("failed to create recursive watcher: %w", err))
	}
	go func() {
		rw.w.Events <- fsnotify.Event{Name: "test.templ"}
		<-time.After(200 * time.Millisecond)
		rw.w.Events <- fsnotify.Event{Name: "test.templ"}
	}()
	count := 0
	exp := time.After(500 * time.Millisecond)
	for {
		select {
		case <-rw.Events:
			count++
		case <-exp:
			if count != 2 {
				t.Errorf("expected 2 event, got %d", count)
			}
			cancel()
			if err := rw.Close(); err != nil {
				t.Errorf("unexpected error closing watcher: %v", err)
			}
			return
		}
	}
}

func TestWatchIgnoresFilesMatchingIgnorePattern(t *testing.T) {
	ctx, cancel := context.WithCancel(context.Background())
	events := make(chan fsnotify.Event, 2)
	errors := make(chan error)
	watchPattern, err := regexp.Compile(".*")
	if err != nil {
		t.Fatal(fmt.Errorf("failed to compile watch pattern: %w", err))
	}
	ignorePattern, err := regexp.Compile(`ignore\.templ$`)
	if err != nil {
		t.Fatal(fmt.Errorf("failed to compile ignore pattern: %w", err))
	}

	rw, err := Recursive(ctx, watchPattern, ignorePattern, events, errors)
	if err != nil {
		t.Fatal(fmt.Errorf("failed to create recursive watcher: %w", err))
	}

	go func() {
		// This should be ignored
		rw.w.Events <- fsnotify.Event{Name: "file.ignore.templ"}
		// This should pass
		rw.w.Events <- fsnotify.Event{Name: "file.keep.templ"}
	}()

	count := 0
	exp := time.After(300 * time.Millisecond)
	for {
		select {
		case <-rw.Events:
			count++
		case <-exp:
			if count != 1 {
				t.Errorf("expected 1 event, got %d", count)
			}
			cancel()
			if err := rw.Close(); err != nil {
				t.Errorf("unexpected error closing watcher: %v", err)
			}
			return
		}
	}
}

func TestIgnorePatternTakesPrecedenceOverWatchPattern(t *testing.T) {
	ctx, cancel := context.WithCancel(context.Background())
	defer cancel()
	events := make(chan fsnotify.Event, 2)
	errors := make(chan error)
	watchPattern := regexp.MustCompile(`.*\.templ$`)
	ignorePattern := regexp.MustCompile(`.*\.ignore\.templ$`)

	rw, err := Recursive(ctx, watchPattern, ignorePattern, events, errors)
	if err != nil {
		t.Fatal(err)
	}

	go func() {
		rw.w.Events <- fsnotify.Event{Name: "file.ignore.templ"}
	}()

	exp := time.After(300 * time.Millisecond)
	select {
	case <-rw.Events:
		t.Errorf("expected no events because ignore should win")
	case <-exp:
		cancel()
		_ = rw.Close()
	}
}


================================================
FILE: cmd/templ/infocmd/main.go
================================================
package infocmd

import (
	"context"
	"encoding/json"
	"errors"
	"fmt"
	"io"
	"log/slog"
	"os"
	"os/exec"
	"runtime"
	"strings"
	"sync"

	"github.com/a-h/templ"
	"github.com/a-h/templ/cmd/templ/lspcmd/pls"
)

type Arguments struct {
	JSON bool `flag:"json" help:"Output info as JSON."`
}

type Info struct {
	OS struct {
		GOOS   string `json:"goos"`
		GOARCH string `json:"goarch"`
	} `json:"os"`
	Go       ToolInfo `json:"go"`
	Gopls    ToolInfo `json:"gopls"`
	Templ    ToolInfo `json:"templ"`
	Prettier ToolInfo `json:"prettier"`
}

type ToolInfo struct {
	Location string     `json:"location"`
	Version  string     `json:"version"`
	Level    slog.Level `json:"level"`
	Message  string     `json:"message,omitempty"`
}

func getGoInfo() (d ToolInfo) {
	d.Level = slog.LevelError

	var err error
	d.Location, err = exec.LookPath("go")
	if err != nil {
		d.Message = fmt.Sprintf("failed to find go: %v", err)
		return
	}
	cmd := exec.Command(d.Location, "version")
	v, err := cmd.Output()
	if err != nil {
		d.Message = fmt.Sprintf("failed to get go version, check that Go is installed: %v", err)
		return
	}
	d.Version = strings.TrimSpace(string(v))
	d.Level = slog.LevelInfo
	return
}

func getGoplsInfo() (d ToolInfo) {
	d.Level = slog.LevelError

	var err error
	d.Location, err = pls.FindGopls()
	if err != nil {
		d.Message = fmt.Sprintf("failed to find gopls: %v", err)
		return
	}
	cmd := exec.Command(d.Location, "version")
	v, err := cmd.Output()
	if err != nil {
		d.Message = fmt.Sprintf("failed to get gopls version: %v", err)
		return
	}
	d.Version = strings.TrimSpace(string(v))
	d.Level = slog.LevelInfo
	return
}

func getTemplInfo() (d ToolInfo) {
	d.Level = slog.LevelError

	var err error
	d.Location, err = findTempl()
	if err != nil {
		d.Message = err.Error()
		return
	}
	cmd := exec.Command(d.Location, "version")
	v, err := cmd.Output()
	if err != nil {
		d.Message = fmt.Sprintf("failed to get templ version: %v", err)
		return
	}
	d.Version = strings.TrimSpace(string(v))
	if d.Version != templ.Version() {
		d.Message = fmt.Sprintf("version mismatch - you're running %q at the command line, but the version in the path is %q", templ.Version(), d.Version)
		return
	}
	d.Level = slog.LevelInfo
	return
}

func findTempl() (location string, err error) {
	executableName := "templ"
	if runtime.GOOS == "windows" {
		executableName = "templ.exe"
	}
	executableName, err = exec.LookPath(executableName)
	if err == nil {
		// Found on the path.
		return executableName, nil
	}

	// Unexpected error.
	if !errors.Is(err, exec.ErrNotFound) {
		return "", fmt.Errorf("unexpected error looking for templ: %w", err)
	}

	return "", fmt.Errorf("templ is not in the path (%q). You can install templ with `go install github.com/a-h/templ/cmd/templ@latest`", os.Getenv("PATH"))
}

func getPrettierInfo() (d ToolInfo) {
	d.Level = slog.LevelWarn

	var err error
	d.Location, err = exec.LookPath("prettier")
	if err != nil {
		d.Message = fmt.Sprintf("failed to find prettier: %v", err)
		return
	}
	cmd := exec.Command(d.Location, "--version")
	v, err := cmd.Output()
	if err != nil {
		d.Message = fmt.Sprintf("failed to get prettier version: %v", err)
		return
	}
	d.Version = strings.TrimSpace(string(v))
	d.Level = slog.LevelInfo
	return
}

func getInfo() (d Info) {
	d.OS.GOOS = runtime.GOOS
	d.OS.GOARCH = runtime.GOARCH

	var wg sync.WaitGroup
	wg.Add(4)
	go func() {
		defer wg.Done()
		d.Go = getGoInfo()
	}()
	go func() {
		defer wg.Done()
		d.Gopls = getGoplsInfo()
	}()
	go func() {
		defer wg.Done()
		d.Templ = getTemplInfo()
	}()
	go func() {
		defer wg.Done()
		d.Prettier = getPrettierInfo()
	}()
	wg.Wait()
	return
}

func Run(ctx context.Context, log *slog.Logger, stdout io.Writer, args Arguments) (err error) {
	info := getInfo()
	if args.JSON {
		enc := json.NewEncoder(stdout)
		enc.SetIndent("", "  ")
		return enc.Encode(info)
	}
	log.Info("os", slog.String("goos", info.OS.GOOS), slog.String("goarch", info.OS.GOARCH))
	logInfo(ctx, log, "go", info.Go)
	logInfo(ctx, log, "gopls", info.Gopls)
	logInfo(ctx, log, "templ", info.Templ)
	logInfo(ctx, log, "prettier", info.Prettier)
	return nil
}

func logInfo(ctx context.Context, log *slog.Logger, name string, ti ToolInfo) {
	args := []any{
		slog.String("location", ti.Location),
		slog.String("version", ti.Version),
	}
	if ti.Message != "" {
		args = append(args, slog.String("message", ti.Message))
	}
	log.Log(ctx, ti.Level, name, args...)
}


================================================
FILE: cmd/templ/lspcmd/httpdebug/handler.go
================================================
package httpdebug

import (
	"encoding/json"
	"io"
	"log/slog"
	"net/http"
	"net/url"

	"github.com/a-h/templ"
	"github.com/a-h/templ/cmd/templ/lspcmd/proxy"
	"github.com/a-h/templ/cmd/templ/visualize"
)

var log *slog.Logger

func NewHandler(l *slog.Logger, s *proxy.Server) http.Handler {
	m := http.NewServeMux()
	log = l
	m.HandleFunc("/templ", func(w http.ResponseWriter, r *http.Request) {
		uri := r.URL.Query().Get("uri")
		c, ok := s.TemplSource.Get(uri)
		if !ok {
			Error(w, "uri not found", http.StatusNotFound)
			return
		}
		String(w, c.String())
	})
	m.HandleFunc("/sourcemap", func(w http.ResponseWriter, r *http.Request) {
		uri := r.URL.Query().Get("uri")
		sm, ok := s.SourceMapCache.Get(uri)
		if !ok {
			Error(w, "uri not found", http.StatusNotFound)
			return
		}
		JSON(w, sm.SourceLinesToTarget)
	})
	m.HandleFunc("/go", func(w http.ResponseWriter, r *http.Request) {
		uri := r.URL.Query().Get("uri")
		c, ok := s.GoSource[uri]
		if !ok {
			Error(w, "uri not found", http.StatusNotFound)
			return
		}
		String(w, c)
	})
	m.HandleFunc("/", func(w http.ResponseWriter, r *http.Request) {
		uri := r.URL.Query().Get("uri")
		if uri == "" {
			// List all URIs.
			if err := list(s.TemplSource.URIs()).Render(r.Context(), w); err != nil {
				Error(w, "failed to list URIs", http.StatusInternalServerError)
			}
			return
		}
		// Assume we've got a URI.
		templSource, ok := s.TemplSource.Get(uri)
		if !ok {
			if !ok {
				Error(w, "uri not found in document contents", http.StatusNotFound)
				return
			}
		}
		goSource, ok := s.GoSource[uri]
		if !ok {
			if !ok {
				Error(w, "uri not found in document contents", http.StatusNotFound)
				return
			}
		}
		sm, ok := s.SourceMapCache.Get(uri)
		if !ok {
			Error(w, "uri not found", http.StatusNotFound)
			return
		}
		if err := visualize.HTML(uri, templSource.String(), goSource, sm).Render(r.Context(), w); err != nil {
			Error(w, "failed to visualize HTML", http.StatusInternalServerError)
		}
	})
	return m
}

func getMapURL(uri string) templ.SafeURL {
	return withQuery("/", uri)
}

func getSourceMapURL(uri string) templ.SafeURL {
	return withQuery("/sourcemap", uri)
}

func getTemplURL(uri string) templ.SafeURL {
	return withQuery("/templ", uri)
}

func getGoURL(uri string) templ.SafeURL {
	return withQuery("/go", uri)
}

func withQuery(path, uri string) templ.SafeURL {
	q := make(url.Values)
	q.Set("uri", uri)
	u := &url.URL{
		Path:     path,
		RawPath:  path,
		RawQuery: q.Encode(),
	}
	return templ.SafeURL(u.String())
}

func JSON(w http.ResponseWriter, v any) {
	w.Header().Set("Content-Type", "application/json")
	enc := json.NewEncoder(w)
	enc.SetIndent("", "  ")
	if err := enc.Encode(v); err != nil {
		log.Error("failed to write JSON response", slog.Any("error", err))
	}
}

func String(w http.ResponseWriter, s string) {
	if _, err := io.WriteString(w, s); err != nil {
		log.Error("failed to write string response", slog.Any("error", err))
	}
}

func Error(w http.ResponseWriter, msg string, status int) {
	w.WriteHeader(status)
	if _, err := io.WriteString(w, msg); err != nil {
		log.Error("failed to write error response", slog.Any("error", err))
	}
}


================================================
FILE: cmd/templ/lspcmd/httpdebug/list.templ
================================================
package httpdebug

templ list(uris []string) {
	<table>
		<tr>
			<th>File</th>
			<th></th>
			<th></th>
			<th></th>
			<th></th>
		</tr>
		for _, uri := range uris {
			<tr>
				<td>{ uri }</td>
				<td><a href={ getMapURL(uri) }>Mapping</a></td>
				<td><a href={ getSourceMapURL(uri) }>Source Map</a></td>
				<td><a href={ getTemplURL(uri) }>Templ</a></td>
				<td><a href={ getGoURL(uri) }>Go</a></td>
			</tr>
		}
	</table>
}


================================================
FILE: cmd/templ/lspcmd/httpdebug/list_templ.go
================================================
// Code generated by templ - DO NOT EDIT.

package httpdebug

//lint:file-ignore SA4006 This context is only used if a nested component is present.

import "github.com/a-h/templ"
import templruntime "github.com/a-h/templ/runtime"

func list(uris []string) templ.Component {
	return templruntime.GeneratedTemplate(func(templ_7745c5c3_Input templruntime.GeneratedComponentInput) (templ_7745c5c3_Err error) {
		templ_7745c5c3_W, ctx := templ_7745c5c3_Input.Writer, templ_7745c5c3_Input.Context
		if templ_7745c5c3_CtxErr := ctx.Err(); templ_7745c5c3_CtxErr != nil {
			return templ_7745c5c3_CtxErr
		}
		templ_7745c5c3_Buffer, templ_7745c5c3_IsBuffer := templruntime.GetBuffer(templ_7745c5c3_W)
		if !templ_7745c5c3_IsBuffer {
			defer func() {
				templ_7745c5c3_BufErr := templruntime.ReleaseBuffer(templ_7745c5c3_Buffer)
				if templ_7745c5c3_Err == nil {
					templ_7745c5c3_Err = templ_7745c5c3_BufErr
				}
			}()
		}
		ctx = templ.InitializeContext(ctx)
		templ_7745c5c3_Var1 := templ.GetChildren(ctx)
		if templ_7745c5c3_Var1 == nil {
			templ_7745c5c3_Var1 = templ.NopComponent
		}
		ctx = templ.ClearChildren(ctx)
		templ_7745c5c3_Err = templruntime.WriteString(templ_7745c5c3_Buffer, 1, "<table><tr><th>File</th><th></th><th></th><th></th><th></th></tr>")
		if templ_7745c5c3_Err != nil {
			return templ_7745c5c3_Err
		}
		for _, uri := range uris {
			templ_7745c5c3_Err = templruntime.WriteString(templ_7745c5c3_Buffer, 2, "<tr><td>")
			if templ_7745c5c3_Err != nil {
				return templ_7745c5c3_Err
			}
			var templ_7745c5c3_Var2 string
			templ_7745c5c3_Var2, templ_7745c5c3_Err = templ.JoinStringErrs(uri)
			if templ_7745c5c3_Err != nil {
				return templ.Error{Err: templ_7745c5c3_Err, FileName: `cmd/templ/lspcmd/httpdebug/list.templ`, Line: 14, Col: 13}
			}
			_, templ_7745c5c3_Err = templ_7745c5c3_Buffer.WriteString(templ.EscapeString(templ_7745c5c3_Var2))
			if templ_7745c5c3_Err != nil {
				return templ_7745c5c3_Err
			}
			templ_7745c5c3_Err = templruntime.WriteString(templ_7745c5c3_Buffer, 3, "</td><td><a href=\"")
			if templ_7745c5c3_Err != nil {
				return templ_7745c5c3_Err
			}
			var templ_7745c5c3_Var3 templ.SafeURL
			templ_7745c5c3_Var3, templ_7745c5c3_Err = templ.JoinURLErrs(getMapURL(uri))
			if templ_7745c5c3_Err != nil {
				return templ.Error{Err: templ_7745c5c3_Err, FileName: `cmd/templ/lspcmd/httpdebug/list.templ`, Line: 15, Col: 32}
			}
			_, templ_7745c5c3_Err = templ_7745c5c3_Buffer.WriteString(templ.EscapeString(templ_7745c5c3_Var3))
			if templ_7745c5c3_Err != nil {
				return templ_7745c5c3_Err
			}
			templ_7745c5c3_Err = templruntime.WriteString(templ_7745c5c3_Buffer, 4, "\">Mapping</a></td><td><a href=\"")
			if templ_7745c5c3_Err != nil {
				return templ_7745c5c3_Err
			}
			var templ_7745c5c3_Var4 templ.SafeURL
			templ_7745c5c3_Var4, templ_7745c5c3_Err = templ.JoinURLErrs(getSourceMapURL(uri))
			if templ_7745c5c3_Err != nil {
				return templ.Error{Err: templ_7745c5c3_Err, FileName: `cmd/templ/lspcmd/httpdebug/list.templ`, Line: 16, Col: 38}
			}
			_, templ_7745c5c3_Err = templ_7745c5c3_Buffer.WriteString(templ.EscapeString(templ_7745c5c3_Var4))
			if templ_7745c5c3_Err != nil {
				return templ_7745c5c3_Err
			}
			templ_7745c5c3_Err = templruntime.WriteString(templ_7745c5c3_Buffer, 5, "\">Source Map</a></td><td><a href=\"")
			if templ_7745c5c3_Err != nil {
				return templ_7745c5c3_Err
			}
			var templ_7745c5c3_Var5 templ.SafeURL
			templ_7745c5c3_Var5, templ_7745c5c3_Err = templ.JoinURLErrs(getTemplURL(uri))
			if templ_7745c5c3_Err != nil {
				return templ.Error{Err: templ_7745c5c3_Err, FileName: `cmd/templ/lspcmd/httpdebug/list.templ`, Line: 17, Col: 34}
			}
			_, templ_7745c5c3_Err = templ_7745c5c3_Buffer.WriteString(templ.EscapeString(templ_7745c5c3_Var5))
			if templ_7745c5c3_Err != nil {
				return templ_7745c5c3_Err
			}
			templ_7745c5c3_Err = templruntime.WriteString(templ_7745c5c3_Buffer, 6, "\">Templ</a></td><td><a href=\"")
			if templ_7745c5c3_Err != nil {
				return templ_7745c5c3_Err
			}
			var templ_7745c5c3_Var6 templ.SafeURL
			templ_7745c5c3_Var6, templ_7745c5c3_Err = templ.JoinURLErrs(getGoURL(uri))
			if templ_7745c5c3_Err != nil {
				return templ.Error{Err: templ_7745c5c3_Err, FileName: `cmd/templ/lspcmd/httpdebug/list.templ`, Line: 18, Col: 31}
			}
			_, templ_7745c5c3_Err = templ_7745c5c3_Buffer.WriteString(templ.EscapeString(templ_7745c5c3_Var6))
			if templ_7745c5c3_Err != nil {
				return templ_7745c5c3_Err
			}
			templ_7745c5c3_Err = templruntime.WriteString(templ_7745c5c3_Buffer, 7, "\">Go</a></td></tr>")
			if templ_7745c5c3_Err != nil {
				return templ_7745c5c3_Err
			}
		}
		templ_7745c5c3_Err = templruntime.WriteString(templ_7745c5c3_Buffer, 8, "</table>")
		if templ_7745c5c3_Err != nil {
			return templ_7745c5c3_Err
		}
		return nil
	})
}

var _ = templruntime.GeneratedTemplate


================================================
FILE: cmd/templ/lspcmd/lsp_test.go
================================================
package lspcmd

import (
	"bytes"
	"context"
	"fmt"
	"io"
	"log/slog"
	"os"
	"strings"
	"sync"
	"testing"
	"time"
	"unicode/utf8"

	"github.com/a-h/templ/cmd/templ/generatecmd/modcheck"
	"github.com/a-h/templ/cmd/templ/lspcmd/lspdiff"
	"github.com/a-h/templ/cmd/templ/testproject"
	"github.com/a-h/templ/lsp/jsonrpc2"
	"github.com/a-h/templ/lsp/protocol"
	"github.com/a-h/templ/lsp/uri"
	"github.com/google/go-cmp/cmp"
)

func TestCompletion(t *testing.T) {
	if testing.Short() {
		return
	}

	ctx, cancel := context.WithCancel(context.Background())
	testOutput := bytes.NewBuffer(nil)
	log := slog.New(slog.NewJSONHandler(testOutput, nil))
	defer func() {
		if t.Failed() {
			fmt.Println(testOutput.String())
		}
	}()

	ctx, appDir, _, server, teardown, err := Setup(ctx, log)
	if err != nil {
		t.Fatalf("failed to setup test: %v", err)
	}
	defer teardown(t)
	defer cancel()

	templFile, err := os.ReadFile(appDir + "/templates.templ")
	if err != nil {
		t.Errorf("failed to read file %q: %v", appDir+"/templates.templ", err)
		return
	}
	err = server.DidOpen(ctx, &protocol.DidOpenTextDocumentParams{
		TextDocument: protocol.TextDocumentItem{
			URI:        uri.URI("file://" + appDir + "/templates.templ"),
			LanguageID: "templ",
			Version:    1,
			Text:       string(templFile),
		},
	})
	if err != nil {
		t.Errorf("failed to register open file: %v", err)
		return
	}
	log.Info("Calling completion")

	globalSnippetsLen := 1

	// Edit the file.
	// Replace:
	// <div data-testid="count">{ fmt.Sprintf("%d", count) }</div>
	// With various tests:
	// <div data-testid="count">{ f
	tests := []struct {
		line        int
		replacement string
		cursor      string
		assert      func(t *testing.T, cl *protocol.CompletionList) (msg string, ok bool)
	}{
		{
			line:        13,
			replacement: ` <div data-testid="count">{  `,
			cursor:      `                            ^`,
			assert: func(t *testing.T, actual *protocol.CompletionList) (msg string, ok bool) {
				if actual == nil || len(actual.Items) == globalSnippetsLen {
					return "expected completion list not to be empty or just the default", false
				}
				return "", true
			},
		},
		{
			line:        13,
			replacement: ` <div data-testid="count">{ fmt.`,
			cursor:      `                               ^`,
			assert: func(t *testing.T, actual *protocol.CompletionList) (msg string, ok bool) {
				if !lspdiff.CompletionListContainsText(actual, "fmt.Sprintf") {
					return fmt.Sprintf("expected fmt.Sprintf to be in the completion list, but got %#v", actual), false
				}
				return "", true
			},
		},
		{
			line:        13,
			replacement: ` <div data-testid="count">{ fmt.Sprintf("%d",`,
			cursor:      `                                            ^`,
			assert: func(t *testing.T, actual *protocol.CompletionList) (msg string, ok bool) {
				if actual != nil && len(actual.Items) != globalSnippetsLen {
					return "expected completion list to be empty", false
				}
				return "", true
			},
		},
	}

	for i, test := range tests {
		t.Run(fmt.Sprintf("test-%d", i), func(t *testing.T) {
			// Edit the file.
			updated := testproject.MustReplaceLine(string(templFile), test.line, test.replacement)
			err = server.DidChange(ctx, &protocol.DidChangeTextDocumentParams{
				TextDocument: protocol.VersionedTextDocumentIdentifier{
					TextDocumentIdentifier: protocol.TextDocumentIdentifier{
						URI: uri.URI("file://" + appDir + "/templates.templ"),
					},
					Version: int32(i + 2),
				},
				ContentChanges: []protocol.TextDocumentContentChangeEvent{
					{
						Range: nil,
						Text:  updated,
					},
				},
			})
			if err != nil {
				t.Errorf("failed to change file: %v", err)
				return
			}

			// Give CI/CD pipeline executors some time because they're often quite slow.
			var ok bool
			var msg string
			for range 3 {
				actual, err := server.Completion(ctx, &protocol.CompletionParams{
					Context: &protocol.CompletionContext{
						TriggerCharacter: ".",
						TriggerKind:      protocol.CompletionTriggerKindTriggerCharacter,
					},
					TextDocumentPositionParams: protocol.TextDocumentPositionParams{
						TextDocument: protocol.TextDocumentIdentifier{
							URI: uri.URI("file://" + appDir + "/templates.templ"),
						},
						// Positions are zero indexed.
						Position: protocol.Position{
							Line:      uint32(test.line - 1),
							Character: uint32(len(test.cursor) - 1),
						},
					},
				})
				if err != nil {
					t.Errorf("failed to get completion: %v", err)
					return
				}
				msg, ok = test.assert(t, actual)
				if !ok {
					break
				}
				time.Sleep(time.Millisecond * 500)
			}
			if !ok {
				t.Error(msg)
			}
		})
	}
	log.Info("Completed test")
}

func TestHover(t *testing.T) {
	if testing.Short() {
		return
	}

	ctx, cancel := context.WithCancel(context.Background())
	testOutput := bytes.NewBuffer(nil)
	log := slog.New(slog.NewJSONHandler(testOutput, nil))
	defer func() {
		if t.Failed() {
			fmt.Println(testOutput.String())
		}
	}()

	ctx, appDir, _, server, teardown, err := Setup(ctx, log)
	if err != nil {
		t.Fatalf("failed to setup test: %v", err)
	}
	defer teardown(t)
	defer cancel()

	templFile, err := os.ReadFile(appDir + "/templates.templ")
	if err != nil {
		t.Fatalf("failed to read file %q: %v", appDir+"/templates.templ", err)
	}
	err = server.DidOpen(ctx, &protocol.DidOpenTextDocumentParams{
		TextDocument: protocol.TextDocumentItem{
			URI:        uri.URI("file://" + appDir + "/templates.templ"),
			LanguageID: "templ",
			Version:    1,
			Text:       string(templFile),
		},
	})
	if err != nil {
		t.Errorf("failed to register open file: %v", err)
		return
	}
	log.Info("Calling hover")

	// Edit the file.
	// Replace:
	// <div data-testid="count">{ fmt.Sprintf("%d", count) }</div>
	// With various tests:
	// <div data-testid="count">{ f
	tests := []struct {
		line        int
		replacement string
		cursor      string
		assert      func(t *testing.T, hr *protocol.Hover) (msg string, ok bool)
	}{
		{
			line:        13,
			replacement: `			<div data-testid="count">{ fmt.Sprintf("%d", count) }</div>`,
			cursor:      `                                 ^`,
			assert: func(t *testing.T, actual *protocol.Hover) (msg string, ok bool) {
				if actual.Contents.Kind != "markdown" {
					return fmt.Sprintf("expected hover kind to be markdown, got %q", actual.Contents.Kind), false
				}
				if !strings.Contains(actual.Contents.Value, "```go\npackage fmt\n```") {
					r
Download .txt
gitextract_x0_4cpga/

├── .dockerignore
├── .envrc
├── .github/
│   ├── FUNDING.yml
│   ├── ISSUE_TEMPLATE/
│   │   └── bug_report.md
│   ├── copilot-instructions.md
│   └── workflows/
│       ├── ci.yml
│       ├── docs.yaml
│       ├── flakehub-publish-tagged.yml
│       └── release.yml
├── .gitignore
├── .goreleaser.yaml
├── .ignore
├── .version
├── CODE_OF_CONDUCT.md
├── CONTRIBUTING.md
├── LICENSE
├── README.md
├── SECURITY.md
├── benchmarks/
│   ├── react/
│   │   ├── .gitignore
│   │   ├── README.md
│   │   ├── package.json
│   │   └── src/
│   │       └── index.jsx
│   └── templ/
│       ├── README.md
│       ├── data.go
│       ├── render_test.go
│       ├── template.templ
│       └── template_templ.go
├── cfg/
│   └── cfg.go
├── cmd/
│   └── templ/
│       ├── fmtcmd/
│       │   ├── main.go
│       │   ├── main_test.go
│       │   └── testdata.txtar
│       ├── generatecmd/
│       │   ├── cmd.go
│       │   ├── eventhandler.go
│       │   ├── fatalerror.go
│       │   ├── main.go
│       │   ├── main_test.go
│       │   ├── modcheck/
│       │   │   ├── modcheck.go
│       │   │   └── modcheck_test.go
│       │   ├── proxy/
│       │   │   ├── proxy.go
│       │   │   ├── proxy_test.go
│       │   │   └── script.js
│       │   ├── run/
│       │   │   ├── run_test.go
│       │   │   ├── run_unix.go
│       │   │   ├── run_windows.go
│       │   │   └── testprogram/
│       │   │       ├── go.mod.embed
│       │   │       └── main.go
│       │   ├── sse/
│       │   │   └── server.go
│       │   ├── symlink/
│       │   │   └── symlink_test.go
│       │   ├── test-eventhandler/
│       │   │   ├── eventhandler_test.go
│       │   │   ├── multiple_errors.templ.error
│       │   │   └── single_error.templ.error
│       │   ├── testwatch/
│       │   │   ├── generate_test.go
│       │   │   └── testdata/
│       │   │       ├── go.mod.embed
│       │   │       ├── go.sum
│       │   │       ├── main.go
│       │   │       ├── templates.templ
│       │   │       └── templates_templ.go
│       │   └── watcher/
│       │       ├── watch.go
│       │       └── watch_test.go
│       ├── infocmd/
│       │   └── main.go
│       ├── lspcmd/
│       │   ├── httpdebug/
│       │   │   ├── handler.go
│       │   │   ├── list.templ
│       │   │   └── list_templ.go
│       │   ├── lsp_test.go
│       │   ├── lspdiff/
│       │   │   └── lspdiff.go
│       │   ├── main.go
│       │   ├── pls/
│       │   │   └── main.go
│       │   ├── proxy/
│       │   │   ├── client.go
│       │   │   ├── diagnosticcache.go
│       │   │   ├── documentcontents.go
│       │   │   ├── documentcontents_test.go
│       │   │   ├── import_test.go
│       │   │   ├── rewrite.go
│       │   │   ├── server.go
│       │   │   ├── snippets.go
│       │   │   ├── sourcemapcache.go
│       │   │   └── sourcemapcache_test.go
│       │   └── stdrwc.go
│       ├── main.go
│       ├── main_test.go
│       ├── processor/
│       │   ├── processor.go
│       │   └── processor_test.go
│       ├── sloghandler/
│       │   └── handler.go
│       ├── testproject/
│       │   ├── testdata/
│       │   │   ├── css-classes/
│       │   │   │   └── classes.go
│       │   │   ├── go.mod.embed
│       │   │   ├── go.sum
│       │   │   ├── main.go
│       │   │   ├── remotechild.templ
│       │   │   ├── remotechild_templ.go
│       │   │   ├── remoteparent.templ
│       │   │   ├── remoteparent_templ.go
│       │   │   ├── templates.templ
│       │   │   └── templates_templ.go
│       │   └── testproject.go
│       └── visualize/
│           ├── sourcemapvisualisation.templ
│           ├── sourcemapvisualisation_templ.go
│           └── types.go
├── cosign.pub
├── docs/
│   ├── .gitignore
│   ├── README.md
│   ├── babel.config.js
│   ├── docs/
│   │   ├── 02-quick-start/
│   │   │   ├── 01-installation.md
│   │   │   ├── 02-creating-a-simple-templ-component.md
│   │   │   ├── 03-running-your-first-templ-application.md
│   │   │   └── _category_.json
│   │   ├── 03-syntax-and-usage/
│   │   │   ├── 01-basic-syntax.md
│   │   │   ├── 02-elements.md
│   │   │   ├── 03-attributes.md
│   │   │   ├── 04-expressions.md
│   │   │   ├── 05-statements.md
│   │   │   ├── 06-if-else.md
│   │   │   ├── 07-switch.md
│   │   │   ├── 08-loops.md
│   │   │   ├── 09-raw-go.md
│   │   │   ├── 10-template-composition.md
│   │   │   ├── 11-forms.md
│   │   │   ├── 12-css-style-management.md
│   │   │   ├── 13-script-templates.md
│   │   │   ├── 14-comments.md
│   │   │   ├── 15-context.md
│   │   │   ├── 16-using-with-go-templates.md
│   │   │   ├── 17-rendering-raw-html.md
│   │   │   ├── 18-render-once.md
│   │   │   ├── 19-fragments.md
│   │   │   ├── 20-using-react-with-templ.md
│   │   │   └── _category_.json
│   │   ├── 04-core-concepts/
│   │   │   ├── 01-components.md
│   │   │   ├── 02-template-generation.md
│   │   │   ├── 03-testing.md
│   │   │   ├── 04-view-models.md
│   │   │   └── _category_.json
│   │   ├── 05-server-side-rendering/
│   │   │   ├── 01-creating-an-http-server-with-templ.md
│   │   │   ├── 02-example-counter-application.md
│   │   │   ├── 03-htmx.md
│   │   │   ├── 04-datastar.md
│   │   │   ├── 05-streaming.md
│   │   │   └── _category_.json
│   │   ├── 06-static-rendering/
│   │   │   ├── 01-generating-static-html-files-with-templ.md
│   │   │   ├── 02-blog-example.md
│   │   │   ├── 03-deploying-static-files.md
│   │   │   └── _category_.json
│   │   ├── 07-project-structure/
│   │   │   ├── 01-project-structure.md
│   │   │   └── _category_.json
│   │   ├── 08-hosting-and-deployment/
│   │   │   ├── 01-hosting-on-aws-lambda.md
│   │   │   ├── 02-hosting-using-docker.md
│   │   │   └── _category_.json
│   │   ├── 09-developer-tools/
│   │   │   ├── 01-cli.md
│   │   │   ├── 02-ide-support.md
│   │   │   ├── 03-live-reload.md
│   │   │   ├── 04-live-reload-with-other-tools.md
│   │   │   ├── 05-llm.md
│   │   │   ├── 06-cicd.md
│   │   │   └── _category_.json
│   │   ├── 10-security/
│   │   │   ├── 01-injection-attacks.md
│   │   │   ├── 02-content-security-policy.md
│   │   │   ├── 03-code-signing.md
│   │   │   └── _category_.json
│   │   ├── 11-media/
│   │   │   ├── _category_.json
│   │   │   └── index.md
│   │   ├── 12-integrations/
│   │   │   ├── 01-web-frameworks.md
│   │   │   ├── 02-internationalization.md
│   │   │   └── _category_.json
│   │   ├── 13-experimental/
│   │   │   ├── 01-overview.md
│   │   │   ├── 02-urlbuilder.md
│   │   │   └── _category_.json
│   │   ├── 14-help-and-community/
│   │   │   ├── _category_.json
│   │   │   └── index.md
│   │   ├── 15-component-libraries/
│   │   │   ├── _category_.json
│   │   │   └── index.md
│   │   ├── 16-faq/
│   │   │   ├── _category_.json
│   │   │   └── index.md
│   │   ├── go.mod
│   │   ├── go.sum
│   │   ├── index.md
│   │   └── main.go
│   ├── docusaurus.config.js
│   ├── package.json
│   ├── sidebars.js
│   ├── src/
│   │   ├── css/
│   │   │   └── custom.css
│   │   └── theme/
│   │       └── prism-include-languages.js
│   └── static/
│       ├── .nojekyll
│       └── img/
│           └── shadowdom.webm
├── examples/
│   ├── blog/
│   │   ├── go.mod
│   │   ├── go.sum
│   │   ├── main.go
│   │   ├── posts.templ
│   │   ├── posts_templ.go
│   │   └── posts_test.go
│   ├── content-security-policy/
│   │   ├── main.go
│   │   ├── templates.templ
│   │   └── templates_templ.go
│   ├── counter/
│   │   ├── Dockerfile
│   │   ├── README.md
│   │   ├── assets/
│   │   │   ├── css/
│   │   │   │   └── bulma.css
│   │   │   └── favicon/
│   │   │       ├── about.txt
│   │   │       └── site.webmanifest
│   │   ├── cdk/
│   │   │   ├── .gitignore
│   │   │   ├── cdk.json
│   │   │   └── stack.go
│   │   ├── components/
│   │   │   ├── components.templ
│   │   │   └── components_templ.go
│   │   ├── db/
│   │   │   └── db.go
│   │   ├── go.mod
│   │   ├── go.sum
│   │   ├── handlers/
│   │   │   └── default.go
│   │   ├── lambda/
│   │   │   └── main.go
│   │   ├── main.go
│   │   ├── services/
│   │   │   └── count.go
│   │   └── session/
│   │       └── session.go
│   ├── counter-basic/
│   │   ├── .dockerignore
│   │   ├── Dockerfile
│   │   ├── README.md
│   │   ├── assets/
│   │   │   ├── bulma.css
│   │   │   └── favicon/
│   │   │       ├── about.txt
│   │   │       └── site.webmanifest
│   │   ├── components.templ
│   │   ├── components_templ.go
│   │   ├── fly.toml
│   │   ├── go.mod
│   │   ├── go.sum
│   │   └── main.go
│   ├── external-libraries/
│   │   ├── components.templ
│   │   ├── components_templ.go
│   │   ├── go.mod
│   │   ├── go.sum
│   │   └── main.go
│   ├── hello-world-ssr/
│   │   ├── hello.templ
│   │   ├── hello_templ.go
│   │   └── main.go
│   ├── hello-world-static/
│   │   ├── hello.templ
│   │   ├── hello_templ.go
│   │   └── main.go
│   ├── htmx-fragments/
│   │   ├── README.md
│   │   ├── go.mod
│   │   ├── go.sum
│   │   ├── main.templ
│   │   └── main_templ.go
│   ├── integration-chi/
│   │   ├── go.mod
│   │   ├── go.sum
│   │   ├── home.templ
│   │   ├── home_templ.go
│   │   └── main.go
│   ├── integration-echo/
│   │   ├── go.mod
│   │   ├── go.sum
│   │   ├── home.templ
│   │   ├── home_templ.go
│   │   └── main.go
│   ├── integration-gin/
│   │   ├── gintemplrenderer/
│   │   │   └── renderer.go
│   │   ├── go.mod
│   │   ├── go.sum
│   │   ├── home.html
│   │   ├── home.templ
│   │   ├── home_templ.go
│   │   └── main.go
│   ├── integration-go-echarts/
│   │   ├── components.templ
│   │   ├── components_templ.go
│   │   ├── go.mod
│   │   ├── go.sum
│   │   └── main.go
│   ├── integration-gofiber/
│   │   ├── README.md
│   │   ├── go.mod
│   │   ├── go.sum
│   │   ├── home.templ
│   │   ├── home_templ.go
│   │   └── main.go
│   ├── integration-react/
│   │   ├── README.md
│   │   ├── components.templ
│   │   ├── components_templ.go
│   │   ├── flake.nix
│   │   ├── go.mod
│   │   ├── go.sum
│   │   ├── main.go
│   │   ├── react/
│   │   │   ├── .gitignore
│   │   │   ├── components.tsx
│   │   │   ├── index.ts
│   │   │   ├── package.json
│   │   │   └── tsconfig.json
│   │   └── static/
│   │       └── index.js
│   ├── internationalization/
│   │   ├── components.templ
│   │   ├── components_templ.go
│   │   ├── go.mod
│   │   ├── go.sum
│   │   ├── locales/
│   │   │   ├── de/
│   │   │   │   └── de.yaml
│   │   │   ├── en/
│   │   │   │   └── en.yaml
│   │   │   ├── locales.go
│   │   │   └── zh-cn/
│   │   │       └── zh-cn.yaml
│   │   └── main.go
│   ├── static-generator/
│   │   ├── .gitignore
│   │   ├── Dockerfile
│   │   ├── blog.templ
│   │   ├── blog_templ.go
│   │   ├── fly.toml
│   │   ├── go.mod
│   │   ├── go.sum
│   │   └── main.go
│   ├── streaming/
│   │   ├── go.mod
│   │   ├── go.sum
│   │   ├── main.templ
│   │   └── main_templ.go
│   ├── suspense/
│   │   ├── go.mod
│   │   ├── go.sum
│   │   ├── main.templ
│   │   └── main_templ.go
│   ├── syntax-and-usage/
│   │   └── components/
│   │       ├── main.go
│   │       ├── templsyntax.templ
│   │       └── templsyntax_templ.go
│   └── typescript/
│       ├── README.md
│       ├── assets/
│       │   └── js/
│       │       └── index.js
│       ├── components/
│       │   ├── index.templ
│       │   └── index_templ.go
│       ├── go.mod
│       ├── go.sum
│       ├── main.go
│       └── ts/
│           ├── package.json
│           └── src/
│               └── index.ts
├── flake.nix
├── flush.go
├── flush_test.go
├── fragment.go
├── fragment_test.go
├── generator/
│   ├── generator.go
│   ├── generator_test.go
│   ├── htmldiff/
│   │   └── diff.go
│   ├── rangewriter.go
│   ├── rangewriter_test.go
│   ├── test-a-href/
│   │   ├── expected.html
│   │   ├── render_test.go
│   │   ├── template.templ
│   │   └── template_templ.go
│   ├── test-attribute-errors/
│   │   ├── expected.html
│   │   ├── render_test.go
│   │   ├── template.templ
│   │   └── template_templ.go
│   ├── test-attribute-escaping/
│   │   ├── expected.html
│   │   ├── render_test.go
│   │   ├── template.templ
│   │   └── template_templ.go
│   ├── test-call/
│   │   ├── expected.html
│   │   ├── render_test.go
│   │   ├── template.templ
│   │   └── template_templ.go
│   ├── test-cancelled-context/
│   │   ├── render_test.go
│   │   ├── template.templ
│   │   └── template_templ.go
│   ├── test-class-whitespace/
│   │   ├── expected.html
│   │   ├── render_test.go
│   │   ├── template.templ
│   │   └── template_templ.go
│   ├── test-complex-attributes/
│   │   ├── expected.html
│   │   ├── render_test.go
│   │   ├── template.templ
│   │   └── template_templ.go
│   ├── test-constant-attribute-escaping/
│   │   ├── expected.html
│   │   ├── render_test.go
│   │   ├── template.templ
│   │   └── template_templ.go
│   ├── test-context/
│   │   ├── expected.html
│   │   ├── render_test.go
│   │   ├── template.templ
│   │   └── template_templ.go
│   ├── test-css-expression/
│   │   ├── constants.go
│   │   ├── render_test.go
│   │   ├── template.templ
│   │   └── template_templ.go
│   ├── test-css-middleware/
│   │   ├── expected.html
│   │   ├── render_test.go
│   │   ├── template.templ
│   │   └── template_templ.go
│   ├── test-css-usage/
│   │   ├── expected.html
│   │   ├── render_test.go
│   │   ├── template.templ
│   │   └── template_templ.go
│   ├── test-doctype/
│   │   ├── expected.html
│   │   ├── render_test.go
│   │   ├── template.templ
│   │   └── template_templ.go
│   ├── test-doctype-html4/
│   │   ├── expected.html
│   │   ├── render_test.go
│   │   ├── template.templ
│   │   └── template_templ.go
│   ├── test-element-attributes/
│   │   ├── data.go
│   │   ├── expected.html
│   │   ├── render_test.go
│   │   ├── template.templ
│   │   └── template_templ.go
│   ├── test-elseif/
│   │   ├── data.go
│   │   ├── expected.html
│   │   ├── render_test.go
│   │   ├── template.templ
│   │   └── template_templ.go
│   ├── test-for/
│   │   ├── expected.html
│   │   ├── render_test.go
│   │   ├── template.templ
│   │   └── template_templ.go
│   ├── test-form-action/
│   │   ├── expected.html
│   │   ├── render_test.go
│   │   ├── template.templ
│   │   └── template_templ.go
│   ├── test-fragment/
│   │   ├── complete.html
│   │   ├── render_test.go
│   │   ├── template.templ
│   │   └── template_templ.go
│   ├── test-go-comments/
│   │   ├── expected.html
│   │   ├── render_test.go
│   │   ├── template.templ
│   │   └── template_templ.go
│   ├── test-go-template-in-templ/
│   │   ├── expected.html
│   │   ├── render_test.go
│   │   ├── template.templ
│   │   └── template_templ.go
│   ├── test-html/
│   │   ├── data.go
│   │   ├── expected.html
│   │   ├── render_test.go
│   │   ├── template.templ
│   │   └── template_templ.go
│   ├── test-html-comment/
│   │   ├── expected.html
│   │   ├── render_test.go
│   │   ├── template.templ
│   │   └── template_templ.go
│   ├── test-if/
│   │   ├── data.go
│   │   ├── expected.html
│   │   ├── render_test.go
│   │   ├── template.templ
│   │   └── template_templ.go
│   ├── test-ifelse/
│   │   ├── data.go
│   │   ├── expected.html
│   │   ├── render_test.go
│   │   ├── template.templ
│   │   └── template_templ.go
│   ├── test-import/
│   │   ├── expected.html
│   │   ├── render_test.go
│   │   ├── template.templ
│   │   └── template_templ.go
│   ├── test-js-unsafe-usage/
│   │   ├── expected.html
│   │   ├── render_test.go
│   │   ├── template.templ
│   │   └── template_templ.go
│   ├── test-js-usage/
│   │   ├── expected.html
│   │   ├── render_test.go
│   │   ├── template.templ
│   │   └── template_templ.go
│   ├── test-method/
│   │   ├── expected.html
│   │   ├── render_test.go
│   │   ├── template.templ
│   │   └── template_templ.go
│   ├── test-once/
│   │   ├── expected.html
│   │   ├── render_test.go
│   │   ├── template.templ
│   │   └── template_templ.go
│   ├── test-only-scripts/
│   │   ├── expected.html
│   │   ├── render_test.go
│   │   ├── template.templ
│   │   └── template_templ.go
│   ├── test-primitives/
│   │   ├── expected.html
│   │   ├── render_test.go
│   │   ├── template.templ
│   │   └── template_templ.go
│   ├── test-raw-elements/
│   │   ├── expected.html
│   │   ├── render_test.go
│   │   ├── template.templ
│   │   └── template_templ.go
│   ├── test-script-expressions/
│   │   ├── expected.html
│   │   ├── render_test.go
│   │   ├── template.templ
│   │   └── template_templ.go
│   ├── test-script-inline/
│   │   ├── expected.html
│   │   ├── render_test.go
│   │   ├── template.templ
│   │   └── template_templ.go
│   ├── test-script-usage/
│   │   ├── expected.html
│   │   ├── render_test.go
│   │   ├── template.templ
│   │   └── template_templ.go
│   ├── test-script-usage-nonce/
│   │   ├── expected.html
│   │   ├── render_test.go
│   │   ├── template.templ
│   │   └── template_templ.go
│   ├── test-spread-attributes/
│   │   ├── expected.html
│   │   ├── expected_numeric_attributes.html
│   │   ├── expected_ordered_attributes.html
│   │   ├── render_test.go
│   │   ├── template.templ
│   │   └── template_templ.go
│   ├── test-string/
│   │   ├── expected.html
│   │   ├── render_test.go
│   │   ├── template.templ
│   │   └── template_templ.go
│   ├── test-string-errors/
│   │   ├── expected.html
│   │   ├── render_test.go
│   │   ├── template.templ
│   │   └── template_templ.go
│   ├── test-style-attribute/
│   │   ├── expected.html
│   │   ├── render_test.go
│   │   ├── template.templ
│   │   └── template_templ.go
│   ├── test-switch/
│   │   ├── render_test.go
│   │   ├── template.templ
│   │   └── template_templ.go
│   ├── test-switchdefault/
│   │   ├── render_test.go
│   │   ├── template.templ
│   │   └── template_templ.go
│   ├── test-templ-element/
│   │   ├── expected.html
│   │   ├── render_test.go
│   │   ├── template.templ
│   │   └── template_templ.go
│   ├── test-templ-in-go-template/
│   │   ├── expected.html
│   │   ├── render_test.go
│   │   ├── template.templ
│   │   └── template_templ.go
│   ├── test-text/
│   │   ├── expected.html
│   │   ├── render_test.go
│   │   ├── template.templ
│   │   └── template_templ.go
│   ├── test-text-whitespace/
│   │   ├── render_test.go
│   │   ├── template.templ
│   │   └── template_templ.go
│   ├── test-void/
│   │   ├── expected.html
│   │   ├── render_test.go
│   │   ├── template.templ
│   │   └── template_templ.go
│   └── test-whitespace-around-go-keywords/
│       ├── render_test.go
│       ├── template.templ
│       └── template_templ.go
├── go.mod
├── go.sum
├── handler.go
├── handler_test.go
├── internal/
│   ├── format/
│   │   ├── format_test.go
│   │   ├── scriptelement.go
│   │   ├── styleelement.go
│   │   ├── templ.go
│   │   └── testdata/
│   │       ├── all_children_indented__with_nested_indentation__when_close_tag_is_on_new_line.txt
│   │       ├── all_children_indented__with_nested_indentation__when_close_tag_is_on_same_line.txt
│   │       ├── br_and_hr_all_on_one_line_are_not_placed_on_new_lines.txt
│   │       ├── br_elements_are_placed_on_new_lines.txt
│   │       ├── children_indented__closing_elm.txt
│   │       ├── children_indented__first_child.txt
│   │       ├── comments_are_preserved.txt
│   │       ├── conditional_expressions_have_the_same_child_indentation_rules_as_regular_elements.txt
│   │       ├── conditional_expressions_result_in_all_attrs_indented.txt
│   │       ├── conditional_expressions_result_in_all_attrs_indented__2.txt
│   │       ├── conditional_expressions_with_else_blocks_are_also_formatted.txt
│   │       ├── constant_attributes_prerfer_double_quotes__but_use_single_quotes_if_required.txt
│   │       ├── css_is_indented_by_one_level.txt
│   │       ├── css_whitespace_is_tidied.txt
│   │       ├── cssarguments_multiline.txt
│   │       ├── empty_elements_stay_on_the_same_line.txt
│   │       ├── for_loops_are_placed_on_a_new_line.txt
│   │       ├── formatting_does_not_alter_whitespace.txt
│   │       ├── go_expressions_are_formatted_by_the_go_formatter.txt
│   │       ├── go_expressions_have_whitespace_normalised.txt
│   │       ├── godoc_comments_are_preserved.txt
│   │       ├── if_statements_are_placed_on_a_new_line.txt
│   │       ├── inline_elements_are_not_placed_on_a_new_line.txt
│   │       ├── inline_func_blank_lines_no_whitespace.txt
│   │       ├── multiline_string_literal_indentation_preserved.txt
│   │       ├── non_empty_elements_with_children_that_are_all_on_the_same_line_are_not_split_into_multiple_lines.txt
│   │       ├── raw_go_is_formatted.txt
│   │       ├── script_tags_are_not_converted_to_self_closing_elements.txt
│   │       ├── scriptarguments_multiline.txt
│   │       ├── scriptelement_contents_are_formatted.txt
│   │       ├── scriptelements_hyperscript_is_ignored.txt
│   │       ├── scriptelements_with_go_code_are_formatted.txt
│   │       ├── scriptelements_with_multiple_go_code_sections_are_formatted.txt
│   │       ├── scriptelements_within_templ_expressions_are_formatted.txt
│   │       ├── spacing_between_string_expressions_is_kept.txt
│   │       ├── spacing_between_string_expressions_is_not_magically_added.txt
│   │       ├── spacing_between_string_spreads_attributes_is_kept.txt
│   │       ├── styleelements_are_formatted.txt
│   │       ├── switch_statements_are_placed_on_a_new_line.txt
│   │       ├── tables_are_formatted_well.txt
│   │       ├── templ_expression_attributes_are_formatted_correctly_when_multiline.txt
│   │       ├── templ_expression_elements_are_formatted_the_same_as_other_elements.txt
│   │       ├── templatearguments_multiline_with_generics.txt
│   │       ├── templatefile_can_be_round_tripped.txt
│   │       ├── templatefile_can_start_with_comments.txt
│   │       ├── templatefile_can_start_with_comments_and_whitespace.txt
│   │       ├── templatefile_can_start_with_multiline_comments_and_whitespace.txt
│   │       ├── templatefile_can_start_with_multiple_comments_and_whitespace.txt
│   │       ├── templateheader_with_build_tags.txt
│   │       ├── templelement_multiline_block_containing_multiline_block.txt
│   │       ├── templelement_multiline_block_indentation.txt
│   │       ├── templelement_multiline_in_div.txt
│   │       ├── templelement_param_spacing.txt
│   │       ├── templelement_simple_block_indentation.txt
│   │       ├── templelement_simple_in_div.txt
│   │       ├── templelement_simple_no_change.txt
│   │       ├── void_elements_are_converted_to_self_closing_elements.txt
│   │       └── when_an_element_contains_children_that_are_on_new_lines__the_children_are_indented.txt
│   ├── htmlfind/
│   │   ├── htmlfind.go
│   │   └── htmlfind_test.go
│   ├── imports/
│   │   ├── process.go
│   │   ├── process_test.go
│   │   └── testdata/
│   │       ├── comments.txtar
│   │       ├── commentsbeforepackage.txtar
│   │       ├── deleteimports.txtar
│   │       ├── extraspace.txtar
│   │       ├── groups.txtar
│   │       ├── groupsmanynewlines.txtar
│   │       ├── header.txtar
│   │       ├── hyphenatedimport.txtar
│   │       ├── namedimportsadd.txtar
│   │       ├── namedimportsremoved.txtar
│   │       ├── noimports.txtar
│   │       ├── noimportscode.txtar
│   │       ├── stringexp.txtar
│   │       └── twoimports.txtar
│   ├── lazyloader/
│   │   ├── docheader.go
│   │   ├── docheader_test.go
│   │   ├── docheaderparser.go
│   │   ├── docheaderparser_test.go
│   │   ├── pkgloader.go
│   │   ├── pkgloader_test.go
│   │   ├── pkgtraverser.go
│   │   ├── pkgtraverser_test.go
│   │   ├── templdoclazyloader.go
│   │   └── templdoclazyloader_test.go
│   ├── prettier/
│   │   ├── prettier.go
│   │   ├── prettier_test.go
│   │   └── testdata.txtar
│   ├── skipdir/
│   │   ├── skipdir.go
│   │   └── skipdir_test.go
│   ├── syncmap/
│   │   ├── map.go
│   │   └── map_test.go
│   └── syncset/
│       ├── set.go
│       └── set_test.go
├── join.go
├── join_test.go
├── js.go
├── js_test.go
├── jsonscript.go
├── jsonscript_test.go
├── jsonstring.go
├── jsonstring_test.go
├── lsp/
│   ├── LICENSE
│   ├── README.md
│   ├── jsonrpc2/
│   │   ├── codes.go
│   │   ├── conn.go
│   │   ├── errors.go
│   │   ├── handler.go
│   │   ├── jsonrpc2.go
│   │   ├── jsonrpc2_test.go
│   │   ├── message.go
│   │   ├── serve.go
│   │   ├── serve_test.go
│   │   ├── stream.go
│   │   ├── wire.go
│   │   └── wire_test.go
│   ├── protocol/
│   │   ├── base.go
│   │   ├── base_test.go
│   │   ├── basic.go
│   │   ├── basic_test.go
│   │   ├── callhierarchy.go
│   │   ├── callhierarchy_test.go
│   │   ├── capabilities_client.go
│   │   ├── capabilities_client_test.go
│   │   ├── capabilities_server.go
│   │   ├── client.go
│   │   ├── context.go
│   │   ├── deprecated.go
│   │   ├── diagnostics.go
│   │   ├── diagnostics_test.go
│   │   ├── doc.go
│   │   ├── errors.go
│   │   ├── general.go
│   │   ├── general_test.go
│   │   ├── handler.go
│   │   ├── language.go
│   │   ├── language_test.go
│   │   ├── progress.go
│   │   ├── progress_test.go
│   │   ├── protocol.go
│   │   ├── registration.go
│   │   ├── registration_test.go
│   │   ├── selectionrange.go
│   │   ├── semantic_token.go
│   │   ├── server.go
│   │   ├── text.go
│   │   ├── text_test.go
│   │   ├── util.go
│   │   ├── util_test.go
│   │   ├── version.go
│   │   ├── window.go
│   │   ├── window_test.go
│   │   ├── workspace.go
│   │   └── workspace_test.go
│   ├── uri/
│   │   ├── uri.go
│   │   └── uri_test.go
│   └── xcontext/
│       └── xcontext.go
├── once.go
├── once_test.go
├── parser/
│   └── v2/
│       ├── allocs_test.go
│       ├── benchmarks_test.go
│       ├── benchmarktestdata/
│       │   └── benchmark.txt
│       ├── calltemplateparser.go
│       ├── calltemplateparser_test.go
│       ├── childrenparser.go
│       ├── childrenparser_test.go
│       ├── conditionalattributeparser.go
│       ├── cssparser.go
│       ├── cssparser_test.go
│       ├── diagnostics.go
│       ├── diagnostics_test.go
│       ├── doctypeparser.go
│       ├── doctypeparser_test.go
│       ├── elementparser.go
│       ├── elementparser_test.go
│       ├── expressionparser.go
│       ├── expressionparser_test.go
│       ├── fallthroughparser.go
│       ├── fallthroughparser_test.go
│       ├── forexpressionparser.go
│       ├── forexpressionparser_test.go
│       ├── fuzz.sh
│       ├── gocodeparser.go
│       ├── gocodeparser_test.go
│       ├── gocommentparser.go
│       ├── gocommentparser_test.go
│       ├── goexpression/
│       │   ├── fuzz.sh
│       │   ├── parse.go
│       │   ├── parse_test.go
│       │   ├── parsebench_test.go
│       │   ├── scanner.go
│       │   └── testdata/
│       │       └── fuzz/
│       │           ├── FuzzCaseDefault/
│       │           │   ├── 3c6f43d3ec8a900b
│       │           │   ├── 986e7bc325c7890c
│       │           │   └── d8a9a4cd9fc8cb11
│       │           ├── FuzzExpression/
│       │           │   └── ac5d99902f5e7914
│       │           ├── FuzzFuncs/
│       │           │   └── 46c9ed6c9d427bd2
│       │           └── FuzzIf/
│       │               └── 7a174efc13e3fdd6
│       ├── goparser.go
│       ├── htmlcommentparser.go
│       ├── htmlcommentparser_test.go
│       ├── ifexpressionparser.go
│       ├── ifexpressionparser_test.go
│       ├── packageparser.go
│       ├── packageparser_test.go
│       ├── parser.go
│       ├── raw.go
│       ├── raw_test.go
│       ├── scriptparser.go
│       ├── scriptparser_test.go
│       ├── scriptparsertestdata/
│       │   ├── backtickquote.txt
│       │   ├── backtickquote_apostrophe.txt
│       │   ├── doublequote.txt
│       │   ├── doublequote_apostrophe.txt
│       │   ├── escapechars.txt
│       │   ├── non_js_script.txt
│       │   ├── regexp_literal.txt
│       │   ├── showsuccessmessage.txt
│       │   ├── singlequote.txt
│       │   ├── singlequote_apostrophe.txt
│       │   └── terminating_comment.txt
│       ├── scripttemplateparser.go
│       ├── scripttemplateparser_test.go
│       ├── sourcemap.go
│       ├── sourcemap_test.go
│       ├── stringexpressionparser.go
│       ├── stringexpressionparser_test.go
│       ├── structure.go
│       ├── switchexpressionparser.go
│       ├── switchexpressionparser_test.go
│       ├── templatefile.go
│       ├── templatefile_test.go
│       ├── templateparser.go
│       ├── templateparser_test.go
│       ├── templelementparser.go
│       ├── templelementparser_test.go
│       ├── testdata/
│       │   └── fuzz/
│       │       └── FuzzScriptParser/
│       │           ├── 0667fe9c719c304f
│       │           ├── 21c86d8a2781524b
│       │           └── 43cd47dd50874af5
│       ├── textparser.go
│       ├── textparser_test.go
│       ├── types.go
│       ├── visitor/
│       │   ├── visitor.go
│       │   └── visitor_test.go
│       ├── visitor.go
│       └── whitespaceparser.go
├── runtime/
│   ├── buffer.go
│   ├── buffer_test.go
│   ├── bufferpool.go
│   ├── bufferpool_test.go
│   ├── builder.go
│   ├── builder_test.go
│   ├── fuzzing/
│   │   ├── fuzz.templ
│   │   ├── fuzz_templ.go
│   │   ├── fuzz_test.go
│   │   ├── go.mod
│   │   ├── go.sum
│   │   └── testdata/
│   │       └── fuzz/
│   │           ├── FuzzComponentAny/
│   │           │   ├── 02bc261247f1267d
│   │           │   ├── 0e3d2540388fc8bd
│   │           │   ├── 0ed510998a1c1a4e
│   │           │   └── 926b62a033ecc0fd
│   │           └── FuzzComponentString/
│   │               ├── 4a59bdc98ee75491
│   │               ├── 66658924a0ea89b6
│   │               └── 9fc8b4df9a42170c
│   ├── runtime.go
│   ├── runtime_test.go
│   ├── scriptelement.go
│   ├── scriptelement_test.go
│   ├── styleattribute.go
│   ├── styleattribute_test.go
│   ├── watchmode.go
│   └── watchmode_test.go
├── runtime.go
├── runtime_test.go
├── safehtml/
│   ├── style.go
│   └── style_test.go
├── scripttemplate.go
├── scripttemplate_test.go
├── storybook/
│   ├── .gitignore
│   ├── _example/
│   │   ├── cdk/
│   │   │   ├── .gitignore
│   │   │   ├── README.md
│   │   │   ├── cdk.go
│   │   │   ├── cdk.json
│   │   │   └── deploy.sh
│   │   ├── go.mod
│   │   ├── go.sum
│   │   ├── lambda/
│   │   │   └── main.go
│   │   ├── local/
│   │   │   └── main.go
│   │   ├── run.sh
│   │   ├── storybook.go
│   │   ├── templates.templ
│   │   └── templates_templ.go
│   ├── _package.json
│   └── storybook.go
├── turbo/
│   ├── stream.go
│   ├── stream.templ
│   ├── stream_templ.go
│   └── stream_test.go
├── url.go
├── url_test.go
├── version.go
└── watchmode.go
Download .txt
Showing preview only (293K chars total). Download the full file or copy to clipboard to get everything.
SYMBOL INDEX (3138 symbols across 400 files)

FILE: benchmarks/templ/data.go
  type Person (line 3) | type Person struct

FILE: benchmarks/templ/render_test.go
  function BenchmarkTemplRender (line 15) | func BenchmarkTemplRender(b *testing.B) {
  function BenchmarkTemplParser (line 35) | func BenchmarkTemplParser(b *testing.B) {
  function BenchmarkGoTemplateRender (line 59) | func BenchmarkGoTemplateRender(b *testing.B) {
  constant html (line 75) | html = `<div><h1>Luiz Bonfa</h1><div style="font-family: &#39;sans-serif...
  function BenchmarkIOWriteString (line 77) | func BenchmarkIOWriteString(b *testing.B) {

FILE: benchmarks/templ/template_templ.go
  function Render (line 10) | func Render(p Person) templ.Component {

FILE: cfg/cfg.go
  type Flags (line 9) | type Flags struct
  function parse (line 13) | func parse() *Flags {

FILE: cmd/templ/fmtcmd/main.go
  type Arguments (line 18) | type Arguments struct
  function Run (line 28) | func Run(log *slog.Logger, stdin io.Reader, stdout io.Writer, args Argum...
  type Formatter (line 76) | type Formatter struct
    method Run (line 98) | func (f *Formatter) Run() (err error) {
  function NewFormatter (line 84) | func NewFormatter(log *slog.Logger, dir string, process func(fileName st...

FILE: cmd/templ/fmtcmd/main_test.go
  type testProject (line 20) | type testProject struct
  type testFile (line 26) | type testFile struct
  function setupProjectDir (line 31) | func setupProjectDir() (tp testProject, err error) {
  function TestFormat (line 59) | func TestFormat(t *testing.T) {

FILE: cmd/templ/generatecmd/cmd.go
  function NewGenerate (line 35) | func NewGenerate(log *slog.Logger, args Arguments) (g *Generate, err err...
  type Generate (line 43) | type Generate struct
    method Run (line 55) | func (cmd Generate) Run(ctx context.Context) (err error) {
    method groupUntilNoMessagesReceivedFor100ms (line 182) | func (cmd Generate) groupUntilNoMessagesReceivedFor100ms(postGeneratio...
    method handlePostGenerationEvents (line 216) | func (cmd Generate) handlePostGenerationEvents(ctx context.Context, po...
    method handleEvents (line 279) | func (cmd Generate) handleEvents(ctx context.Context, events chan fsno...
    method walkAndWatch (line 312) | func (cmd *Generate) walkAndWatch(ctx context.Context, events chan fsn...
    method deleteWatchModeTextFiles (line 344) | func (cmd *Generate) deleteWatchModeTextFiles() error {
    method createTLSTransport (line 367) | func (cmd *Generate) createTLSTransport() *http.Transport {
    method startProxy (line 383) | func (cmd *Generate) startProxy() (p *proxy.Handler, err error) {
  type GenerationEvent (line 48) | type GenerationEvent struct

FILE: cmd/templ/generatecmd/eventhandler.go
  type FileWriterFunc (line 30) | type FileWriterFunc
  function FileWriter (line 32) | func FileWriter(fileName string, contents []byte) error {
  function WriterFileWriter (line 36) | func WriterFileWriter(w io.Writer) FileWriterFunc {
  function NewFSEventHandler (line 43) | func NewFSEventHandler(
  type FSEventHandler (line 73) | type FSEventHandler struct
    method HandleEvent (line 99) | func (h *FSEventHandler) HandleEvent(ctx context.Context, event fsnoti...
    method generate (line 184) | func (h *FSEventHandler) generate(ctx context.Context, fileName string...
  type GenerateResult (line 90) | type GenerateResult struct
  function goFileIsUpToDate (line 173) | func goFileIsUpToDate(templFileName string, templFileLastMod time.Time) ...
  function remapErrorList (line 257) | func remapErrorList(err error, sourceMap *parser.SourceMap, fileName str...
  function generateSourceMapVisualisation (line 278) | func generateSourceMapVisualisation(ctx context.Context, templFileName, ...

FILE: cmd/templ/generatecmd/fatalerror.go
  type FatalError (line 3) | type FatalError struct
    method Error (line 7) | func (e FatalError) Error() string {
    method Unwrap (line 11) | func (e FatalError) Unwrap() error {
    method Is (line 15) | func (e FatalError) Is(target error) bool {
    method As (line 20) | func (e FatalError) As(target any) bool {

FILE: cmd/templ/generatecmd/main.go
  constant generateUsageText (line 18) | generateUsageText = `usage: templ generate [<args>...]
  constant defaultWatchPattern (line 82) | defaultWatchPattern = `(.+\.go$)|(.+\.templ$)`
  function NewArguments (line 84) | func NewArguments(stdout, stderr io.Writer, args []string) (cmdArgs Argu...
  type Arguments (line 150) | type Arguments struct
  type ArgumentError (line 175) | type ArgumentError struct
    method Error (line 179) | func (e *ArgumentError) Error() string {
    method Code (line 183) | func (a *ArgumentError) Code() int {
  function Run (line 187) | func Run(ctx context.Context, stdout, stderr io.Writer, args []string) (...

FILE: cmd/templ/generatecmd/main_test.go
  function TestGenerate (line 19) | func TestGenerate(t *testing.T) {
  function TestDefaultWatchPattern (line 116) | func TestDefaultWatchPattern(t *testing.T) {
  function TestArgs (line 187) | func TestArgs(t *testing.T) {

FILE: cmd/templ/generatecmd/modcheck/modcheck.go
  function WalkUp (line 15) | func WalkUp(dir string) (string, error) {
  function Check (line 47) | func Check(dir string) error {

FILE: cmd/templ/generatecmd/modcheck/modcheck_test.go
  function TestPatchGoVersion (line 9) | func TestPatchGoVersion(t *testing.T) {

FILE: cmd/templ/generatecmd/proxy/proxy.go
  type Handler (line 30) | type Handler struct
    method modifyResponse (line 132) | func (h *Handler) modifyResponse(r *http.Response) error {
    method ServeHTTP (line 292) | func (p *Handler) ServeHTTP(w http.ResponseWriter, r *http.Request) {
    method SendSSE (line 319) | func (p *Handler) SendSSE(eventType string, data string) {
  function reloadScript (line 38) | func reloadScript(nonce string) *html.Node {
  function insertScriptTagIntoBody (line 54) | func insertScriptTagIntoBody(nonce, body string) (updated string, err er...
  function isStreaming (line 71) | func isStreaming(r *http.Response, log *slog.Logger) bool {
  function streamInsertAfterBodyOpen (line 84) | func streamInsertAfterBodyOpen(nonce string, r io.Reader, w io.Writer) e...
  type passthroughWriteCloser (line 122) | type passthroughWriteCloser struct
    method Close (line 126) | func (pwc passthroughWriteCloser) Close() error {
  constant unsupportedContentEncoding (line 130) | unsupportedContentEncoding = "Unsupported content encoding, hot reload s...
  function parseNonce (line 251) | func parseNonce(csp string) (nonce string) {
  function New (line 273) | func New(log *slog.Logger, scheme string, bind string, port int, target ...
  type roundTripper (line 323) | type roundTripper struct
    method setShouldSkipResponseModificationHeader (line 329) | func (rt *roundTripper) setShouldSkipResponseModificationHeader(r *htt...
    method RoundTrip (line 338) | func (rt *roundTripper) RoundTrip(r *http.Request) (*http.Response, er...
  function NotifyProxy (line 377) | func NotifyProxy(host string, port int) error {

FILE: cmd/templ/generatecmd/proxy/proxy_test.go
  function TestRoundTripper (line 26) | func TestRoundTripper(t *testing.T) {
  function getScriptTag (line 65) | func getScriptTag(t *testing.T, nonce string) string {
  function TestProxy (line 75) | func TestProxy(t *testing.T) {
  function newTestLogHandler (line 669) | func newTestLogHandler(level slog.Level) *testLogHandler {
  type testLogHandler (line 677) | type testLogHandler struct
    method Enabled (line 683) | func (h *testLogHandler) Enabled(ctx context.Context, l slog.Level) bo...
    method Handle (line 687) | func (h *testLogHandler) Handle(ctx context.Context, r slog.Record) er...
    method WithAttrs (line 697) | func (h *testLogHandler) WithAttrs(attrs []slog.Attr) slog.Handler {
    method WithGroup (line 701) | func (h *testLogHandler) WithGroup(name string) slog.Handler {
  function TestParseNonce (line 705) | func TestParseNonce(t *testing.T) {
  function TestStreamInsertAfterBodyOpen (line 761) | func TestStreamInsertAfterBodyOpen(t *testing.T) {

FILE: cmd/templ/generatecmd/run/run_test.go
  function TestGoRun (line 20) | func TestGoRun(t *testing.T) {
  function readResponse (line 92) | func readResponse(url string) (body string, err error) {

FILE: cmd/templ/generatecmd/run/run_unix.go
  function KillAll (line 22) | func KillAll() (err error) {
  function kill (line 35) | func kill(cmd *exec.Cmd) (err error) {
  function ignoreExited (line 44) | func ignoreExited(err error) error {
  function Run (line 55) | func Run(ctx context.Context, workingDir string, input string) (cmd *exe...

FILE: cmd/templ/generatecmd/run/run_windows.go
  function KillAll (line 19) | func KillAll() (err error) {
  function Stop (line 35) | func Stop(cmd *exec.Cmd) (err error) {
  function Run (line 42) | func Run(ctx context.Context, workingDir string, input string) (cmd *exe...

FILE: cmd/templ/generatecmd/run/testprogram/main.go
  function main (line 28) | func main() {

FILE: cmd/templ/generatecmd/sse/server.go
  function New (line 12) | func New() *Handler {
  type Handler (line 19) | type Handler struct
    method Send (line 31) | func (s *Handler) Send(eventType string, data string) {
    method ServeHTTP (line 45) | func (s *Handler) ServeHTTP(w http.ResponseWriter, r *http.Request) {
  type event (line 25) | type event struct

FILE: cmd/templ/generatecmd/symlink/symlink_test.go
  function TestSymlink (line 14) | func TestSymlink(t *testing.T) {

FILE: cmd/templ/generatecmd/test-eventhandler/eventhandler_test.go
  function extractErrorList (line 21) | func extractErrorList(err error) (scanner.ErrorList, bool) {
  function TestErrorLocationMapping (line 33) | func TestErrorLocationMapping(t *testing.T) {

FILE: cmd/templ/generatecmd/testwatch/generate_test.go
  function createTestProject (line 30) | func createTestProject(moduleRoot string) (dir string, err error) {
  function replaceInFile (line 59) | func replaceInFile(name, src, tgt string) error {
  function getPort (line 68) | func getPort() (port int, err error) {
  function getHTML (line 81) | func getHTML(url string) (n *html.Node, err error) {
  function TestCanAccessDirect (line 92) | func TestCanAccessDirect(t *testing.T) {
  function TestCanAccessViaProxy (line 121) | func TestCanAccessViaProxy(t *testing.T) {
  type Event (line 150) | type Event struct
  function readSSE (line 155) | func readSSE(ctx context.Context, url string, sse chan<- Event) (err err...
  function TestFileModificationsResultInSSEWithGzip (line 189) | func TestFileModificationsResultInSSEWithGzip(t *testing.T) {
  function TestFileModificationsResultInSSE (line 265) | func TestFileModificationsResultInSSE(t *testing.T) {
  function NewTestArgs (line 341) | func NewTestArgs(modRoot, appDir string, appPort int, proxyBind string, ...
  type TestArgs (line 353) | type TestArgs struct
  function Setup (line 363) | func Setup(gzipEncoding bool) (args TestArgs, teardown func(t *testing.T...
  function waitForURL (line 424) | func waitForURL(url string) (err error) {
  function TestGenerateReturnsErrors (line 447) | func TestGenerateReturnsErrors(t *testing.T) {

FILE: cmd/templ/generatecmd/testwatch/testdata/main.go
  type GzipResponseWriter (line 16) | type GzipResponseWriter struct
    method Header (line 20) | func (w *GzipResponseWriter) Header() http.Header {
    method Write (line 24) | func (w *GzipResponseWriter) Write(b []byte) (int, error) {
    method WriteHeader (line 43) | func (w *GzipResponseWriter) WriteHeader(statusCode int) {
  function main (line 50) | func main() {

FILE: cmd/templ/generatecmd/testwatch/testdata/templates_templ.go
  function Page (line 12) | func Page(count int) templ.Component {

FILE: cmd/templ/generatecmd/watcher/watch.go
  function Recursive (line 16) | func Recursive(
  function WalkFiles (line 47) | func WalkFiles(ctx context.Context, rootPath string, watchPattern, ignor...
  type RecursiveWatcher (line 73) | type RecursiveWatcher struct
    method Close (line 97) | func (w *RecursiveWatcher) Close() error {
    method loop (line 105) | func (w *RecursiveWatcher) loop() {
    method Add (line 153) | func (w *RecursiveWatcher) Add(dir string) error {
  type timerKey (line 85) | type timerKey struct
  function timerKeyFromEvent (line 90) | func timerKeyFromEvent(event fsnotify.Event) timerKey {

FILE: cmd/templ/generatecmd/watcher/watch_test.go
  function TestWatchDebouncesDuplicates (line 13) | func TestWatchDebouncesDuplicates(t *testing.T) {
  function TestWatchDoesNotDebounceDifferentEvents (line 48) | func TestWatchDoesNotDebounceDifferentEvents(t *testing.T) {
  function TestWatchDoesNotDebounceSeparateEvents (line 102) | func TestWatchDoesNotDebounceSeparateEvents(t *testing.T) {
  function TestWatchIgnoresFilesMatchingIgnorePattern (line 138) | func TestWatchIgnoresFilesMatchingIgnorePattern(t *testing.T) {
  function TestIgnorePatternTakesPrecedenceOverWatchPattern (line 182) | func TestIgnorePatternTakesPrecedenceOverWatchPattern(t *testing.T) {

FILE: cmd/templ/infocmd/main.go
  type Arguments (line 20) | type Arguments struct
  type Info (line 24) | type Info struct
  type ToolInfo (line 35) | type ToolInfo struct
  function getGoInfo (line 42) | func getGoInfo() (d ToolInfo) {
  function getGoplsInfo (line 62) | func getGoplsInfo() (d ToolInfo) {
  function getTemplInfo (line 82) | func getTemplInfo() (d ToolInfo) {
  function findTempl (line 106) | func findTempl() (location string, err error) {
  function getPrettierInfo (line 125) | func getPrettierInfo() (d ToolInfo) {
  function getInfo (line 145) | func getInfo() (d Info) {
  function Run (line 171) | func Run(ctx context.Context, log *slog.Logger, stdout io.Writer, args A...
  function logInfo (line 186) | func logInfo(ctx context.Context, log *slog.Logger, name string, ti Tool...

FILE: cmd/templ/lspcmd/httpdebug/handler.go
  function NewHandler (line 17) | func NewHandler(l *slog.Logger, s *proxy.Server) http.Handler {
  function getMapURL (line 83) | func getMapURL(uri string) templ.SafeURL {
  function getSourceMapURL (line 87) | func getSourceMapURL(uri string) templ.SafeURL {
  function getTemplURL (line 91) | func getTemplURL(uri string) templ.SafeURL {
  function getGoURL (line 95) | func getGoURL(uri string) templ.SafeURL {
  function withQuery (line 99) | func withQuery(path, uri string) templ.SafeURL {
  function JSON (line 110) | func JSON(w http.ResponseWriter, v any) {
  function String (line 119) | func String(w http.ResponseWriter, s string) {
  function Error (line 125) | func Error(w http.ResponseWriter, msg string, status int) {

FILE: cmd/templ/lspcmd/httpdebug/list_templ.go
  function list (line 10) | func list(uris []string) templ.Component {

FILE: cmd/templ/lspcmd/lsp_test.go
  function TestCompletion (line 25) | func TestCompletion(t *testing.T) {
  function TestHover (line 174) | func TestHover(t *testing.T) {
  function TestReferences (line 325) | func TestReferences(t *testing.T) {
  function TestCodeAction (line 492) | func TestCodeAction(t *testing.T) {
  function TestDocumentSymbol (line 621) | func TestDocumentSymbol(t *testing.T) {
  function runeIndexToUTF8ByteIndex (line 760) | func runeIndexToUTF8ByteIndex(s string, runeIndex int) (lspChar uint32, ...
  function NewTestClient (line 774) | func NewTestClient(log *slog.Logger) TestClient {
  type TestClient (line 780) | type TestClient struct
    method Progress (line 784) | func (tc TestClient) Progress(ctx context.Context, params *protocol.Pr...
    method WorkDoneProgressCreate (line 789) | func (tc TestClient) WorkDoneProgressCreate(ctx context.Context, param...
    method LogMessage (line 794) | func (tc TestClient) LogMessage(ctx context.Context, params *protocol....
    method PublishDiagnostics (line 799) | func (tc TestClient) PublishDiagnostics(ctx context.Context, params *p...
    method ShowMessage (line 804) | func (tc TestClient) ShowMessage(ctx context.Context, params *protocol...
    method ShowMessageRequest (line 809) | func (tc TestClient) ShowMessageRequest(ctx context.Context, params *p...
    method Telemetry (line 813) | func (tc TestClient) Telemetry(ctx context.Context, params any) (err e...
    method RegisterCapability (line 818) | func (tc TestClient) RegisterCapability(ctx context.Context, params *p...
    method UnregisterCapability (line 824) | func (tc TestClient) UnregisterCapability(ctx context.Context, params ...
    method ApplyEdit (line 829) | func (tc TestClient) ApplyEdit(ctx context.Context, params *protocol.A...
    method Configuration (line 834) | func (tc TestClient) Configuration(ctx context.Context, params *protoc...
    method WorkspaceFolders (line 839) | func (tc TestClient) WorkspaceFolders(ctx context.Context) (result []p...
  function Setup (line 844) | func Setup(ctx context.Context, log *slog.Logger) (clientCtx context.Con...

FILE: cmd/templ/lspcmd/lspdiff/lspdiff.go
  function CodeAction (line 11) | func CodeAction(expected, actual []protocol.CodeAction) string {
  function CompletionList (line 15) | func CompletionList(expected, actual *protocol.CompletionList) string {
  function References (line 21) | func References(expected, actual []protocol.Location) string {
  function CompletionListContainsText (line 25) | func CompletionListContainsText(cl *protocol.CompletionList, text string...

FILE: cmd/templ/lspcmd/main.go
  type Arguments (line 21) | type Arguments struct
  function Run (line 34) | func Run(stdin io.Reader, stdout, stderr io.Writer, args Arguments) (err...
  function run (line 75) | func run(ctx context.Context, log *slog.Logger, templStream jsonrpc2.Str...

FILE: cmd/templ/lspcmd/pls/main.go
  type Options (line 16) | type Options struct
    method AsArguments (line 23) | func (opts Options) AsArguments() []string {
  function FindGopls (line 37) | func FindGopls() (location string, err error) {
  function NewGopls (line 76) | func NewGopls(ctx context.Context, log *slog.Logger, opts Options) (rwc ...
  function newProcessReadWriteCloser (line 87) | func newProcessReadWriteCloser(logger *slog.Logger, cmd *exec.Cmd) (rwc ...
  type processReadWriteCloser (line 108) | type processReadWriteCloser struct
    method Read (line 113) | func (prwc processReadWriteCloser) Read(p []byte) (n int, err error) {
    method Write (line 117) | func (prwc processReadWriteCloser) Write(p []byte) (n int, err error) {
    method Close (line 121) | func (prwc processReadWriteCloser) Close() error {

FILE: cmd/templ/lspcmd/proxy/client.go
  type Client (line 19) | type Client struct
    method Progress (line 37) | func (p Client) Progress(ctx context.Context, params *lsp.ProgressPara...
    method WorkDoneProgressCreate (line 42) | func (p Client) WorkDoneProgressCreate(ctx context.Context, params *ls...
    method LogMessage (line 47) | func (p Client) LogMessage(ctx context.Context, params *lsp.LogMessage...
    method PublishDiagnostics (line 52) | func (p Client) PublishDiagnostics(ctx context.Context, params *lsp.Pu...
    method ShowMessage (line 102) | func (p Client) ShowMessage(ctx context.Context, params *lsp.ShowMessa...
    method ShowMessageRequest (line 113) | func (p Client) ShowMessageRequest(ctx context.Context, params *lsp.Sh...
    method Telemetry (line 118) | func (p Client) Telemetry(ctx context.Context, params any) (err error) {
    method RegisterCapability (line 123) | func (p Client) RegisterCapability(ctx context.Context, params *lsp.Re...
    method UnregisterCapability (line 128) | func (p Client) UnregisterCapability(ctx context.Context, params *lsp....
    method ApplyEdit (line 133) | func (p Client) ApplyEdit(ctx context.Context, params *lsp.ApplyWorksp...
    method Configuration (line 138) | func (p Client) Configuration(ctx context.Context, params *lsp.Configu...
    method WorkspaceFolders (line 143) | func (p Client) WorkspaceFolders(ctx context.Context) (result []lsp.Wo...
  function NewClient (line 26) | func NewClient(log *slog.Logger, cache *SourceMapCache, diagnosticCache ...

FILE: cmd/templ/lspcmd/proxy/diagnosticcache.go
  function NewDiagnosticCache (line 9) | func NewDiagnosticCache() *DiagnosticCache {
  type fileDiagnostic (line 16) | type fileDiagnostic struct
  type DiagnosticCache (line 21) | type DiagnosticCache struct
    method AddTemplDiagnostics (line 33) | func (dc *DiagnosticCache) AddTemplDiagnostics(uri string, goDiagnosti...
    method ClearTemplDiagnostics (line 44) | func (dc *DiagnosticCache) ClearTemplDiagnostics(uri string) {
    method AddGoDiagnostics (line 52) | func (dc *DiagnosticCache) AddGoDiagnostics(uri string, templDiagnosti...
  function zeroLengthSliceIfNil (line 26) | func zeroLengthSliceIfNil(diags []lsp.Diagnostic) []lsp.Diagnostic {

FILE: cmd/templ/lspcmd/proxy/documentcontents.go
  function newDocumentContents (line 13) | func newDocumentContents(log *slog.Logger) *DocumentContents {
  type DocumentContents (line 21) | type DocumentContents struct
    method Set (line 28) | func (dc *DocumentContents) Set(uri string, d *Document) {
    method Get (line 35) | func (dc *DocumentContents) Get(uri string) (d *Document, ok bool) {
    method Delete (line 43) | func (dc *DocumentContents) Delete(uri string) {
    method URIs (line 49) | func (dc *DocumentContents) URIs() (uris []string) {
    method Apply (line 62) | func (dc *DocumentContents) Apply(uri string, changes []lsp.TextDocume...
  function NewDocument (line 77) | func NewDocument(log *slog.Logger, s string) *Document {
  type Document (line 84) | type Document struct
    method LineLengths (line 89) | func (d *Document) LineLengths() (lens []int) {
    method Len (line 97) | func (d *Document) Len() (line, col int) {
    method Overwrite (line 103) | func (d *Document) Overwrite(fromLine, fromCol, toLine, toCol int, lin...
    method Insert (line 111) | func (d *Document) Insert(line, col int, lines []string) {
    method InsertLines (line 124) | func (d *Document) InsertLines(i int, withLines []string) {
    method Delete (line 128) | func (d *Document) Delete(fromLine, fromCol, toLine, toCol int) {
    method DeleteLines (line 141) | func (d *Document) DeleteLines(i, j int) {
    method String (line 145) | func (d *Document) String() string {
    method Replace (line 149) | func (d *Document) Replace(with string) {
    method Apply (line 153) | func (d *Document) Apply(r *lsp.Range, with string) {
    method normalize (line 173) | func (d *Document) normalize(r *lsp.Range) {
    method isOverwrite (line 194) | func (d *Document) isOverwrite(r *lsp.Range, with string) bool {
    method isInsert (line 198) | func (d *Document) isInsert(r *lsp.Range, with string) bool {
    method isDelete (line 202) | func (d *Document) isDelete(r *lsp.Range, with string) bool {
    method isWholeDocument (line 206) | func (d *Document) isWholeDocument(r *lsp.Range) bool {

FILE: cmd/templ/lspcmd/proxy/documentcontents_test.go
  function TestDocument (line 12) | func TestDocument(t *testing.T) {

FILE: cmd/templ/lspcmd/proxy/import_test.go
  function TestFindLastImport (line 11) | func TestFindLastImport(t *testing.T) {
  function TestGetPackageFromItemDetail (line 267) | func TestGetPackageFromItemDetail(t *testing.T) {

FILE: cmd/templ/lspcmd/proxy/rewrite.go
  function convertTemplToGoURI (line 10) | func convertTemplToGoURI(templURI lsp.DocumentURI) (isTemplFile bool, go...
  function convertTemplGoToTemplURI (line 18) | func convertTemplGoToTemplURI(goURI lsp.DocumentURI) (isTemplGoFile bool...

FILE: cmd/templ/lspcmd/proxy/server.go
  type Server (line 37) | type Server struct
    method updatePosition (line 62) | func (p *Server) updatePosition(templURI lsp.DocumentURI, current lsp....
    method convertTemplRangeToGoRange (line 87) | func (p *Server) convertTemplRangeToGoRange(templURI lsp.DocumentURI, ...
    method convertGoRangeToTemplRange (line 109) | func (p *Server) convertGoRangeToTemplRange(templURI lsp.DocumentURI, ...
    method parseTemplate (line 134) | func (p *Server) parseTemplate(ctx context.Context, uri uri.URI, templ...
    method Initialize (line 220) | func (p *Server) Initialize(ctx context.Context, params *lsp.Initializ...
    method preload (line 263) | func (p *Server) preload(ctx context.Context, workspaceFolders []lsp.W...
    method Initialized (line 325) | func (p *Server) Initialized(ctx context.Context, params *lsp.Initiali...
    method Shutdown (line 341) | func (p *Server) Shutdown(ctx context.Context) (err error) {
    method Exit (line 347) | func (p *Server) Exit(ctx context.Context) (err error) {
    method WorkDoneProgressCancel (line 353) | func (p *Server) WorkDoneProgressCancel(ctx context.Context, params *l...
    method LogTrace (line 359) | func (p *Server) LogTrace(ctx context.Context, params *lsp.LogTracePar...
    method SetTrace (line 365) | func (p *Server) SetTrace(ctx context.Context, params *lsp.SetTracePar...
    method CodeAction (line 373) | func (p *Server) CodeAction(ctx context.Context, params *lsp.CodeActio...
    method CodeLens (line 430) | func (p *Server) CodeLens(ctx context.Context, params *lsp.CodeLensPar...
    method CodeLensResolve (line 457) | func (p *Server) CodeLensResolve(ctx context.Context, params *lsp.Code...
    method ColorPresentation (line 463) | func (p *Server) ColorPresentation(ctx context.Context, params *lsp.Co...
    method Completion (line 492) | func (p *Server) Completion(ctx context.Context, params *lsp.Completio...
    method CompletionResolve (line 635) | func (p *Server) CompletionResolve(ctx context.Context, params *lsp.Co...
    method Declaration (line 641) | func (p *Server) Declaration(ctx context.Context, params *lsp.Declarat...
    method Definition (line 672) | func (p *Server) Definition(ctx context.Context, params *lsp.Definitio...
    method DidChange (line 703) | func (p *Server) DidChange(ctx context.Context, params *lsp.DidChangeT...
    method DidChangeConfiguration (line 766) | func (p *Server) DidChangeConfiguration(ctx context.Context, params *l...
    method DidChangeWatchedFiles (line 772) | func (p *Server) DidChangeWatchedFiles(ctx context.Context, params *ls...
    method DidChangeWorkspaceFolders (line 778) | func (p *Server) DidChangeWorkspaceFolders(ctx context.Context, params...
    method DidClose (line 784) | func (p *Server) DidClose(ctx context.Context, params *lsp.DidCloseTex...
    method HandleDidClose (line 803) | func (p *Server) HandleDidClose(ctx context.Context, params *lsp.DidCl...
    method DidOpen (line 821) | func (p *Server) DidOpen(ctx context.Context, params *lsp.DidOpenTextD...
    method HandleDidOpen (line 838) | func (p *Server) HandleDidOpen(ctx context.Context, params *lsp.DidOpe...
    method DidSave (line 876) | func (p *Server) DidSave(ctx context.Context, params *lsp.DidSaveTextD...
    method DocumentColor (line 885) | func (p *Server) DocumentColor(ctx context.Context, params *lsp.Docume...
    method DocumentHighlight (line 911) | func (p *Server) DocumentHighlight(ctx context.Context, params *lsp.Do...
    method DocumentLink (line 917) | func (p *Server) DocumentLink(ctx context.Context, params *lsp.Documen...
    method DocumentLinkResolve (line 928) | func (p *Server) DocumentLinkResolve(ctx context.Context, params *lsp....
    method DocumentSymbol (line 958) | func (p *Server) DocumentSymbol(ctx context.Context, params *lsp.Docum...
    method convertSymbolRange (line 991) | func (p *Server) convertSymbolRange(templURI lsp.DocumentURI, s *lsp.D...
    method ExecuteCommand (line 1039) | func (p *Server) ExecuteCommand(ctx context.Context, params *lsp.Execu...
    method FoldingRanges (line 1045) | func (p *Server) FoldingRanges(ctx context.Context, params *lsp.Foldin...
    method Formatting (line 1053) | func (p *Server) Formatting(ctx context.Context, params *lsp.DocumentF...
    method Hover (line 1095) | func (p *Server) Hover(ctx context.Context, params *lsp.HoverParams) (...
    method Implementation (line 1124) | func (p *Server) Implementation(ctx context.Context, params *lsp.Imple...
    method OnTypeFormatting (line 1154) | func (p *Server) OnTypeFormatting(ctx context.Context, params *lsp.Doc...
    method PrepareRename (line 1184) | func (p *Server) PrepareRename(ctx context.Context, params *lsp.Prepar...
    method RangeFormatting (line 1211) | func (p *Server) RangeFormatting(ctx context.Context, params *lsp.Docu...
    method References (line 1239) | func (p *Server) References(ctx context.Context, params *lsp.Reference...
    method Rename (line 1271) | func (p *Server) Rename(ctx context.Context, params *lsp.RenameParams)...
    method SignatureHelp (line 1277) | func (p *Server) SignatureHelp(ctx context.Context, params *lsp.Signat...
    method Symbols (line 1293) | func (p *Server) Symbols(ctx context.Context, params *lsp.WorkspaceSym...
    method TypeDefinition (line 1299) | func (p *Server) TypeDefinition(ctx context.Context, params *lsp.TypeD...
    method WillSave (line 1315) | func (p *Server) WillSave(ctx context.Context, params *lsp.WillSaveTex...
    method WillSaveWaitUntil (line 1327) | func (p *Server) WillSaveWaitUntil(ctx context.Context, params *lsp.Wi...
    method ShowDocument (line 1333) | func (p *Server) ShowDocument(ctx context.Context, params *lsp.ShowDoc...
    method WillCreateFiles (line 1339) | func (p *Server) WillCreateFiles(ctx context.Context, params *lsp.Crea...
    method DidCreateFiles (line 1345) | func (p *Server) DidCreateFiles(ctx context.Context, params *lsp.Creat...
    method WillRenameFiles (line 1351) | func (p *Server) WillRenameFiles(ctx context.Context, params *lsp.Rena...
    method DidRenameFiles (line 1357) | func (p *Server) DidRenameFiles(ctx context.Context, params *lsp.Renam...
    method WillDeleteFiles (line 1363) | func (p *Server) WillDeleteFiles(ctx context.Context, params *lsp.Dele...
    method DidDeleteFiles (line 1369) | func (p *Server) DidDeleteFiles(ctx context.Context, params *lsp.Delet...
    method CodeLensRefresh (line 1375) | func (p *Server) CodeLensRefresh(ctx context.Context) (err error) {
    method PrepareCallHierarchy (line 1381) | func (p *Server) PrepareCallHierarchy(ctx context.Context, params *lsp...
    method IncomingCalls (line 1387) | func (p *Server) IncomingCalls(ctx context.Context, params *lsp.CallHi...
    method OutgoingCalls (line 1393) | func (p *Server) OutgoingCalls(ctx context.Context, params *lsp.CallHi...
    method SemanticTokensFull (line 1399) | func (p *Server) SemanticTokensFull(ctx context.Context, params *lsp.S...
    method SemanticTokensFullDelta (line 1410) | func (p *Server) SemanticTokensFullDelta(ctx context.Context, params *...
    method SemanticTokensRange (line 1421) | func (p *Server) SemanticTokensRange(ctx context.Context, params *lsp....
    method SemanticTokensRefresh (line 1432) | func (p *Server) SemanticTokensRefresh(ctx context.Context) (err error) {
    method LinkedEditingRange (line 1438) | func (p *Server) LinkedEditingRange(ctx context.Context, params *lsp.L...
    method Moniker (line 1444) | func (p *Server) Moniker(ctx context.Context, params *lsp.MonikerParam...
    method Request (line 1460) | func (p *Server) Request(ctx context.Context, method string, params an...
  function NewServer (line 49) | func NewServer(log *slog.Logger, target lsp.Server, cache *SourceMapCach...
  function stripTemplStringable (line 576) | func stripTemplStringable(s string) string {
  function getPackageFromItemDetail (line 587) | func getPackageFromItemDetail(pkg string) string {
  type importInsert (line 594) | type importInsert struct
  function addImport (line 601) | func addImport(lines []string, pkg string) (result importInsert) {
  function isRangeWithin (line 1026) | func isRangeWithin(parent, child lsp.Range) bool {

FILE: cmd/templ/lspcmd/proxy/sourcemapcache.go
  function NewSourceMapCache (line 11) | func NewSourceMapCache() *SourceMapCache {
  type SourceMapCache (line 19) | type SourceMapCache struct
    method Set (line 24) | func (fc *SourceMapCache) Set(uri string, m *parser.SourceMap) {
    method Get (line 36) | func (fc *SourceMapCache) Get(uri string) (m *parser.SourceMap, ok boo...
    method Delete (line 43) | func (fc *SourceMapCache) Delete(uri string) {
    method URIs (line 49) | func (fc *SourceMapCache) URIs() (uris []string) {

FILE: cmd/templ/lspcmd/proxy/sourcemapcache_test.go
  function TestSourceMapCache (line 10) | func TestSourceMapCache(t *testing.T) {

FILE: cmd/templ/lspcmd/stdrwc.go
  function newStdRwc (line 10) | func newStdRwc(log *slog.Logger, name string, w io.Writer, r io.Reader) ...
  type stdrwc (line 19) | type stdrwc struct
    method Read (line 26) | func (s stdrwc) Read(p []byte) (int, error) {
    method Write (line 30) | func (s stdrwc) Write(p []byte) (int, error) {
    method Close (line 34) | func (s stdrwc) Close() error {

FILE: cmd/templ/main.go
  function main (line 22) | func main() {
  constant usageText (line 29) | usageText = `usage: templ <command> [<args>...]
  function run (line 43) | func run(stdin io.Reader, stdout, stderr io.Writer, args []string) (code...
  constant infoUsageText (line 68) | infoUsageText = `usage: templ info [<args>...]
  function infoCmd (line 83) | func infoCmd(stdout, stderr io.Writer, args []string) (code int) {
  function generateCmd (line 121) | func generateCmd(stdout, stderr io.Writer, args []string) (code int) {
  type ErrorCode (line 144) | type ErrorCode interface
  constant fmtUsageText (line 149) | fmtUsageText = `usage: templ fmt [<args> ...]
  function fmtCmd (line 185) | func fmtCmd(stdin io.Reader, stdout, stderr io.Writer, args []string) (c...
  constant lspUsageText (line 223) | lspUsageText = `usage: templ lsp [<args> ...]
  function lspCmd (line 246) | func lspCmd(stdin io.Reader, stdout, stderr io.Writer, args []string) (c...

FILE: cmd/templ/main_test.go
  function TestMain (line 12) | func TestMain(t *testing.T) {

FILE: cmd/templ/processor/processor.go
  type Result (line 13) | type Result struct
  function Process (line 20) | func Process(dir string, f func(fileName string) (error, bool), workerCo...
  function FindTemplates (line 31) | func FindTemplates(srcPath string, output chan<- string) (err error) {
  function ProcessChannel (line 46) | func ProcessChannel(templates <-chan string, dir string, f func(fileName...

FILE: cmd/templ/processor/processor_test.go
  function TestFindTemplates (line 8) | func TestFindTemplates(t *testing.T) {

FILE: cmd/templ/sloghandler/handler.go
  function NewLogger (line 13) | func NewLogger(logLevel string, verbose bool, stderr io.Writer) *slog.Lo...
  type Handler (line 34) | type Handler struct
    method Enabled (line 84) | func (h *Handler) Enabled(ctx context.Context, level slog.Level) bool {
    method WithAttrs (line 88) | func (h *Handler) WithAttrs(attrs []slog.Attr) slog.Handler {
    method WithGroup (line 92) | func (h *Handler) WithGroup(name string) slog.Handler {
    method Handle (line 98) | func (h *Handler) Handle(ctx context.Context, r slog.Record) (err erro...
  function NewHandler (line 53) | func NewHandler(w io.Writer, opts *slog.HandlerOptions) *Handler {

FILE: cmd/templ/testproject/testdata/css-classes/classes.go
  constant Header (line 3) | Header = "header"

FILE: cmd/templ/testproject/testdata/main.go
  function main (line 14) | func main() {

FILE: cmd/templ/testproject/testdata/remotechild_templ.go
  function Remote (line 10) | func Remote() templ.Component {

FILE: cmd/templ/testproject/testdata/remoteparent_templ.go
  function RemoteInclusionTest (line 10) | func RemoteInclusionTest() templ.Component {
  function Remote2 (line 39) | func Remote2() templ.Component {

FILE: cmd/templ/testproject/testdata/templates_templ.go
  function Page (line 12) | func Page(count int) templ.Component {
  type Struct (line 56) | type Struct struct

FILE: cmd/templ/testproject/testproject.go
  function Create (line 15) | func Create(moduleRoot string) (dir string, err error) {
  function MustReplaceLine (line 66) | func MustReplaceLine(file string, line int, replacement string) string {

FILE: cmd/templ/visualize/sourcemapvisualisation_templ.go
  function row (line 10) | func row() templ.CSSClass {
  function column (line 20) | func column() templ.CSSClass {
  function code (line 32) | func code() templ.CSSClass {
  function combine (line 42) | func combine(templFileName string, left, right templ.Component) templ.Co...
  function highlight (line 179) | func highlight(sourceId, targetId string) templ.ComponentScript {
  function removeHighlight (line 196) | func removeHighlight(sourceId, targetId string) templ.ComponentScript {
  function mappedCharacter (line 213) | func mappedCharacter(s string, sourceID, targetID string) templ.Component {

FILE: cmd/templ/visualize/types.go
  function HTML (line 15) | func HTML(templFileName string, templContents, goContents string, source...
  type templLines (line 21) | type templLines struct
    method Render (line 26) | func (tl templLines) Render(ctx context.Context, w io.Writer) (err err...
  type goLines (line 55) | type goLines struct
    method Render (line 60) | func (gl goLines) Render(ctx context.Context, w io.Writer) (err error) {

FILE: docs/docs/main.go
  type Section (line 12) | type Section struct
  type ItemToCreate (line 17) | type ItemToCreate struct
  function main (line 24) | func main() {
  function categoryJSON (line 92) | func categoryJSON(position int, label string) string {
  type Category (line 106) | type Category struct

FILE: docs/src/theme/prism-include-languages.js
  function prismIncludeLanguages (line 2) | function prismIncludeLanguages(PrismObject) {

FILE: examples/blog/main.go
  function main (line 11) | func main() {
  function NewPostsHandler (line 25) | func NewPostsHandler() PostsHandler {
  type PostsHandler (line 36) | type PostsHandler struct
    method ServeHTTP (line 41) | func (ph PostsHandler) ServeHTTP(w http.ResponseWriter, r *http.Reques...
  type Post (line 51) | type Post struct

FILE: examples/blog/posts_templ.go
  function headerTemplate (line 15) | func headerTemplate(name string) templ.Component {
  function footerTemplate (line 57) | func footerTemplate() templ.Component {
  function navTemplate (line 99) | func navTemplate() templ.Component {
  function layout (line 128) | func layout(name string) templ.Component {
  function postsTemplate (line 198) | func postsTemplate(posts []Post) templ.Component {
  function home (line 263) | func home() templ.Component {
  function posts (line 310) | func posts(posts []Post) templ.Component {

FILE: examples/blog/posts_test.go
  function TestHeader (line 17) | func TestHeader(t *testing.T) {
  function TestFooter (line 39) | func TestFooter(t *testing.T) {
  function TestNav (line 61) | func TestNav(t *testing.T) {
  function TestHome (line 77) | func TestHome(t *testing.T) {
  function TestPosts (line 106) | func TestPosts(t *testing.T) {
  function TestPostsHandler (line 155) | func TestPostsHandler(t *testing.T) {

FILE: examples/content-security-policy/main.go
  function main (line 15) | func main() {
  function NewCSPMiddleware (line 31) | func NewCSPMiddleware(log *slog.Logger, next http.Handler) *CSPMiddleware {
  type CSPMiddleware (line 39) | type CSPMiddleware struct
    method ServeHTTP (line 45) | func (m *CSPMiddleware) ServeHTTP(w http.ResponseWriter, r *http.Reque...
    method generateNonce (line 57) | func (m *CSPMiddleware) generateNonce() (string, error) {

FILE: examples/content-security-policy/templates_templ.go
  function sayHello (line 10) | func sayHello() templ.ComponentScript {
  function template (line 20) | func template() templ.Component {

FILE: examples/counter-basic/components_templ.go
  function counts (line 12) | func counts(global, user int) templ.Component {
  function form (line 67) | func form() templ.Component {
  function page (line 96) | func page(global, user int) templ.Component {

FILE: examples/counter-basic/main.go
  type GlobalState (line 12) | type GlobalState struct
  function getHandler (line 19) | func getHandler(w http.ResponseWriter, r *http.Request) {
  function postHandler (line 25) | func postHandler(w http.ResponseWriter, r *http.Request) {
  function main (line 42) | func main() {

FILE: examples/counter/cdk/stack.go
  type CounterStackProps (line 19) | type CounterStackProps struct
  function NewCounterStack (line 23) | func NewCounterStack(scope constructs.Construct, id string, props *Count...
  function main (line 131) | func main() {

FILE: examples/counter/components/components_templ.go
  function border (line 12) | func border() templ.CSSClass {
  function counts (line 26) | func counts(global, session int) templ.Component {
  function Page (line 125) | func Page(global, session int) templ.Component {

FILE: examples/counter/db/db.go
  type OptionsFunc (line 14) | type OptionsFunc
  function WithClient (line 16) | func WithClient(client *dynamodb.Client) func(*CountStore) {
  function NewCountStore (line 22) | func NewCountStore(tableName, region string, options ...OptionsFunc) (s ...
  type CountStore (line 39) | type CountStore struct
    method BatchGet (line 58) | func (s CountStore) BatchGet(ctx context.Context, ids ...string) (coun...
    method Get (line 128) | func (s CountStore) Get(ctx context.Context, id string) (count int, er...
    method Increment (line 155) | func (s CountStore) Increment(ctx context.Context, id string) (count i...
  function stripEmpty (line 44) | func stripEmpty(strings []string) (op []string) {
  type countRecord (line 53) | type countRecord struct

FILE: examples/counter/handlers/default.go
  type CountService (line 13) | type CountService interface
  function New (line 18) | func New(log *slog.Logger, cs CountService) *DefaultHandler {
  type DefaultHandler (line 25) | type DefaultHandler struct
    method ServeHTTP (line 30) | func (h *DefaultHandler) ServeHTTP(w http.ResponseWriter, r *http.Requ...
    method Get (line 38) | func (h *DefaultHandler) Get(w http.ResponseWriter, r *http.Request) {
    method Post (line 50) | func (h *DefaultHandler) Post(w http.ResponseWriter, r *http.Request) {
    method View (line 79) | func (h *DefaultHandler) View(w http.ResponseWriter, r *http.Request, ...
  type ViewProps (line 75) | type ViewProps struct

FILE: examples/counter/lambda/main.go
  function main (line 14) | func main() {

FILE: examples/counter/main.go
  function main (line 16) | func main() {

FILE: examples/counter/services/count.go
  type Counts (line 13) | type Counts struct
  type IncrementType (line 18) | type IncrementType
  constant IncrementTypeUnknown (line 21) | IncrementTypeUnknown IncrementType = iota
  constant IncrementTypeGlobal (line 22) | IncrementTypeGlobal
  constant IncrementTypeSession (line 23) | IncrementTypeSession
  function NewCount (line 28) | func NewCount(log *slog.Logger, cs *db.CountStore) Count {
  type Count (line 35) | type Count struct
    method Increment (line 40) | func (cs Count) Increment(ctx context.Context, it IncrementType, sessi...
    method Get (line 71) | func (cs Count) Get(ctx context.Context, sessionID string) (counts Cou...

FILE: examples/counter/session/session.go
  type MiddlewareOpts (line 9) | type MiddlewareOpts
  function NewMiddleware (line 11) | func NewMiddleware(next http.Handler, opts ...MiddlewareOpts) http.Handl...
  function WithSecure (line 23) | func WithSecure(secure bool) MiddlewareOpts {
  function WithHTTPOnly (line 29) | func WithHTTPOnly(httpOnly bool) MiddlewareOpts {
  type Middleware (line 35) | type Middleware struct
    method ServeHTTP (line 49) | func (mw Middleware) ServeHTTP(w http.ResponseWriter, r *http.Request) {
  function ID (line 41) | func ID(r *http.Request) (id string) {

FILE: examples/external-libraries/components_templ.go
  function graph (line 10) | func graph(data []TimeValue) templ.ComponentScript {
  function page (line 22) | func page(data []TimeValue) templ.Component {

FILE: examples/external-libraries/main.go
  type TimeValue (line 9) | type TimeValue struct
  function main (line 14) | func main() {

FILE: examples/hello-world-ssr/hello_templ.go
  function hello (line 10) | func hello(name string) templ.Component {

FILE: examples/hello-world-ssr/main.go
  function main (line 11) | func main() {

FILE: examples/hello-world-static/hello_templ.go
  function hello (line 10) | func hello(name string) templ.Component {

FILE: examples/hello-world-static/main.go
  function main (line 9) | func main() {

FILE: examples/htmx-fragments/main_templ.go
  type PageState (line 16) | type PageState struct
  function Page (line 21) | func Page(state PageState) templ.Component {
  function handleRequest (line 104) | func handleRequest(w http.ResponseWriter, r *http.Request) {
  function main (line 120) | func main() {

FILE: examples/integration-chi/home_templ.go
  function Home (line 10) | func Home() templ.Component {

FILE: examples/integration-chi/main.go
  function main (line 10) | func main() {

FILE: examples/integration-echo/home_templ.go
  function Home (line 10) | func Home() templ.Component {

FILE: examples/integration-echo/main.go
  function main (line 10) | func main() {
  function Render (line 17) | func Render(ctx echo.Context, statusCode int, t templ.Component) error {
  function HomeHandler (line 28) | func HomeHandler(c echo.Context) error {

FILE: examples/integration-gin/gintemplrenderer/renderer.go
  type HTMLTemplRenderer (line 13) | type HTMLTemplRenderer struct
    method Instance (line 17) | func (r *HTMLTemplRenderer) Instance(s string, d any) render.Render {
  function New (line 31) | func New(ctx context.Context, status int, component templ.Component) *Re...
  type Renderer (line 39) | type Renderer struct
    method Render (line 45) | func (t Renderer) Render(w http.ResponseWriter) error {
    method WriteContentType (line 56) | func (t Renderer) WriteContentType(w http.ResponseWriter) {

FILE: examples/integration-gin/home_templ.go
  function Home (line 10) | func Home() templ.Component {

FILE: examples/integration-gin/main.go
  function main (line 10) | func main() {

FILE: examples/integration-go-echarts/components_templ.go
  function Home (line 12) | func Home(chart *charts.Bar) templ.Component {

FILE: examples/integration-go-echarts/main.go
  function generateBarItems (line 14) | func generateBarItems() []opts.BarData {
  function createBarChart (line 22) | func createBarChart() *charts.Bar {
  type Renderable (line 36) | type Renderable interface
  function ConvertChartToTemplComponent (line 41) | func ConvertChartToTemplComponent(chart Renderable) templ.Component {
  function main (line 47) | func main() {

FILE: examples/integration-gofiber/home_templ.go
  function NameFromContext (line 12) | func NameFromContext(ctx context.Context) string {
  function Home (line 19) | func Home(name string) templ.Component {
  function NotFound (line 74) | func NotFound() templ.Component {

FILE: examples/integration-gofiber/main.go
  function main (line 9) | func main() {
  function NotFoundMiddleware (line 25) | func NotFoundMiddleware(c fiber.Ctx) error {
  function Render (line 30) | func Render(c fiber.Ctx, component templ.Component) error {

FILE: examples/integration-react/components_templ.go
  function Hello (line 10) | func Hello(name string) templ.Component {
  function page (line 52) | func page() templ.Component {

FILE: examples/integration-react/main.go
  function main (line 11) | func main() {

FILE: examples/integration-react/react/index.ts
  function renderHello (line 21) | function renderHello(e: HTMLElement) {

FILE: examples/integration-react/static/index.js
  function rf (line 1) | function rf(e){return e===null||typeof e!="object"?null:(e=Zu&&e[Zu]||e[...
  function On (line 1) | function On(e,n,t){this.props=e,this.context=n,this.refs=ni,this.updater...
  function ti (line 1) | function ti(){}
  function zl (line 1) | function zl(e,n,t){this.props=e,this.context=n,this.refs=ni,this.updater...
  function oi (line 1) | function oi(e,n,t){var r,l={},o=null,u=null;if(n!=null)for(r in n.ref!==...
  function lf (line 1) | function lf(e,n){return{$$typeof:st,type:e.type,key:n,ref:e.ref,props:e....
  function Rl (line 1) | function Rl(e){return typeof e=="object"&&e!==null&&e.$$typeof===st}
  function of (line 1) | function of(e){var n={"=":"=0",":":"=2"};return"$"+e.replace(/[=:]/g,fun...
  function Pl (line 1) | function Pl(e,n){return typeof e=="object"&&e!==null&&e.key!=null?of(""+...
  function rr (line 1) | function rr(e,n,t,r,l){var o=typeof e;(o==="undefined"||o==="boolean")&&...
  function tr (line 1) | function tr(e,n,t){if(e==null)return e;var r=[],l=0;return rr(e,r,"","",...
  function uf (line 1) | function uf(e){if(e._status===-1){var n=e._result;n=n(),n.then(function(...
  function Fl (line 1) | function Fl(e,n){var t=e.length;e.push(n);e:for(;0<t;){var r=t-1>>>1,l=e...
  function _e (line 1) | function _e(e){return e.length===0?null:e[0]}
  function ir (line 1) | function ir(e){if(e.length===0)return null;var n=e[0],t=e.pop();if(t!==n...
  function or (line 1) | function or(e,n){var t=e.sortIndex-n.sortIndex;return t!==0?t:e.id-n.id}
  function jl (line 1) | function jl(e){for(var n=_e(Ge);n!==null;){if(n.callback===null)ir(Ge);e...
  function Ul (line 1) | function Ul(e){if(ct=!1,jl(e),!yn)if(_e(Re)!==null)yn=!0,Al(Vl);else{var...
  function Vl (line 1) | function Vl(e,n){yn=!1,ct&&(ct=!1,pi(ft),ft=-1),sr=!0;var t=Z;try{for(jl...
  function hi (line 1) | function hi(){return!(L.unstable_now()-vi<mi)}
  function Ml (line 1) | function Ml(){if(ur!==null){var e=L.unstable_now();vi=e;var n=!0;try{n=u...
  function Al (line 1) | function Al(e){ur=e,ar||(ar=!0,at())}
  function Hl (line 1) | function Hl(e,n){ft=di(function(){e(L.unstable_now())},n)}
  function h (line 1) | function h(e){for(var n="https://reactjs.org/docs/error-decoder.html?inv...
  function Ln (line 1) | function Ln(e,n){bn(e,n),bn(e+"Capture",n)}
  function bn (line 1) | function bn(e,n){for(Dt[e]=n,e=0;e<n.length;e++)Ps.add(n[e])}
  function ff (line 1) | function ff(e){return co.call(ki,e)?!0:co.call(Si,e)?!1:cf.test(e)?ki[e]...
  function df (line 1) | function df(e,n,t,r){if(t!==null&&t.type===0)return!1;switch(typeof n){c...
  function pf (line 1) | function pf(e,n,t,r){if(n===null||typeof n>"u"||df(e,n,t,r))return!0;if(...
  function le (line 1) | function le(e,n,t,r,l,o,u){this.acceptsBooleans=n===2||n===3||n===4,this...
  function lu (line 1) | function lu(e){return e[1].toUpperCase()}
  function ou (line 1) | function ou(e,n,t,r){var l=G.hasOwnProperty(n)?G[n]:null;(l!==null?l.typ...
  function dt (line 1) | function dt(e){return e===null||typeof e!="object"?null:(e=Ei&&e[Ei]||e[...
  function St (line 1) | function St(e){if(Bl===void 0)try{throw Error()}catch(t){var n=t.stack.t...
  function $l (line 2) | function $l(e,n){if(!e||Wl)return"";Wl=!0;var t=Error.prepareStackTrace;...
  function mf (line 5) | function mf(e){switch(e.tag){case 5:return St(e.type);case 16:return St(...
  function vo (line 5) | function vo(e){if(e==null)return null;if(typeof e=="function")return e.d...
  function vf (line 5) | function vf(e){var n=e.type;switch(e.tag){case 24:return"Cache";case 9:r...
  function dn (line 5) | function dn(e){switch(typeof e){case"boolean":case"number":case"string":...
  function Rs (line 5) | function Rs(e){var n=e.type;return(e=e.nodeName)&&e.toLowerCase()==="inp...
  function hf (line 5) | function hf(e){var n=Rs(e)?"checked":"value",t=Object.getOwnPropertyDesc...
  function fr (line 5) | function fr(e){e._valueTracker||(e._valueTracker=hf(e))}
  function Os (line 5) | function Os(e){if(!e)return!1;var n=e._valueTracker;if(!n)return!0;var t...
  function Vr (line 5) | function Vr(e){if(e=e||(typeof document<"u"?document:void 0),typeof e>"u...
  function ho (line 5) | function ho(e,n){var t=n.checked;return j({},n,{defaultChecked:void 0,de...
  function _i (line 5) | function _i(e,n){var t=n.defaultValue==null?"":n.defaultValue,r=n.checke...
  function Ds (line 5) | function Ds(e,n){n=n.checked,n!=null&&ou(e,"checked",n,!1)}
  function yo (line 5) | function yo(e,n){Ds(e,n);var t=dn(n.value),r=n.type;if(t!=null)r==="numb...
  function Ci (line 5) | function Ci(e,n,t){if(n.hasOwnProperty("value")||n.hasOwnProperty("defau...
  function go (line 5) | function go(e,n,t){(n!=="number"||Vr(e.ownerDocument)!==e)&&(t==null?e.d...
  function Yn (line 5) | function Yn(e,n,t,r){if(e=e.options,n){n={};for(var l=0;l<t.length;l++)n...
  function wo (line 5) | function wo(e,n){if(n.dangerouslySetInnerHTML!=null)throw Error(h(91));r...
  function xi (line 5) | function xi(e,n){var t=n.value;if(t==null){if(t=n.children,n=n.defaultVa...
  function Ms (line 5) | function Ms(e,n){var t=dn(n.value),r=dn(n.defaultValue);t!=null&&(t=""+t...
  function Ni (line 5) | function Ni(e){var n=e.textContent;n===e._wrapperState.initialValue&&n!=...
  function Is (line 5) | function Is(e){switch(e){case"svg":return"http://www.w3.org/2000/svg";ca...
  function So (line 5) | function So(e,n){return e==null||e==="http://www.w3.org/1999/xhtml"?Is(n...
  function Mt (line 5) | function Mt(e,n){if(n){var t=e.firstChild;if(t&&t===e.lastChild&&t.nodeT...
  function js (line 5) | function js(e,n,t){return n==null||typeof n=="boolean"||n===""?"":t||typ...
  function Us (line 5) | function Us(e,n){e=e.style;for(var t in n)if(n.hasOwnProperty(t)){var r=...
  function ko (line 5) | function ko(e,n){if(n){if(gf[e]&&(n.children!=null||n.dangerouslySetInne...
  function Eo (line 5) | function Eo(e,n){if(e.indexOf("-")===-1)return typeof n.is=="string";swi...
  function au (line 5) | function au(e){return e=e.target||e.srcElement||window,e.correspondingUs...
  function Pi (line 5) | function Pi(e){if(e=qt(e)){if(typeof Co!="function")throw Error(h(280));...
  function Vs (line 5) | function Vs(e){Xn?Gn?Gn.push(e):Gn=[e]:Xn=e}
  function As (line 5) | function As(){if(Xn){var e=Xn,n=Gn;if(Gn=Xn=null,Pi(e),n)for(e=0;e<n.len...
  function Hs (line 5) | function Hs(e,n){return e(n)}
  function Bs (line 5) | function Bs(){}
  function Ws (line 5) | function Ws(e,n,t){if(Ql)return e(n,t);Ql=!0;try{return Hs(e,n,t)}finall...
  function It (line 5) | function It(e,n){var t=e.stateNode;if(t===null)return null;var r=pl(t);i...
  function wf (line 5) | function wf(e,n,t,r,l,o,u,i,s){var f=Array.prototype.slice.call(argument...
  function kf (line 5) | function kf(e,n,t,r,l,o,u,i,s){xt=!1,Ar=null,wf.apply(Sf,arguments)}
  function Ef (line 5) | function Ef(e,n,t,r,l,o,u,i,s){if(kf.apply(this,arguments),xt){if(xt){va...
  function Rn (line 5) | function Rn(e){var n=e,t=e;if(e.alternate)for(;n.return;)n=n.return;else...
  function $s (line 5) | function $s(e){if(e.tag===13){var n=e.memoizedState;if(n===null&&(e=e.al...
  function zi (line 5) | function zi(e){if(Rn(e)!==e)throw Error(h(188))}
  function _f (line 5) | function _f(e){var n=e.alternate;if(!n){if(n=Rn(e),n===null)throw Error(...
  function Qs (line 5) | function Qs(e){return e=_f(e),e!==null?Ks(e):null}
  function Ks (line 5) | function Ks(e){if(e.tag===5||e.tag===6)return e;for(e=e.child;e!==null;)...
  function zf (line 5) | function zf(e){if(Ie&&typeof Ie.onCommitFiberRoot=="function")try{Ie.onC...
  function Rf (line 5) | function Rf(e){return e>>>=0,e===0?32:31-(Tf(e)/Lf|0)|0}
  function Et (line 5) | function Et(e){switch(e&-e){case 1:return 1;case 2:return 2;case 4:retur...
  function Wr (line 5) | function Wr(e,n){var t=e.pendingLanes;if(t===0)return 0;var r=0,l=e.susp...
  function Of (line 5) | function Of(e,n){switch(e){case 1:case 2:case 4:return n+250;case 8:case...
  function Df (line 5) | function Df(e,n){for(var t=e.suspendedLanes,r=e.pingedLanes,l=e.expirati...
  function Po (line 5) | function Po(e){return e=e.pendingLanes&-1073741825,e!==0?e:e&1073741824?...
  function Zs (line 5) | function Zs(){var e=pr;return pr<<=1,!(pr&4194240)&&(pr=64),e}
  function Kl (line 5) | function Kl(e){for(var n=[],t=0;31>t;t++)n.push(e);return n}
  function Zt (line 5) | function Zt(e,n,t){e.pendingLanes|=n,n!==536870912&&(e.suspendedLanes=0,...
  function Mf (line 5) | function Mf(e,n){var t=e.pendingLanes&~n;e.pendingLanes=n,e.suspendedLan...
  function fu (line 5) | function fu(e,n){var t=e.entangledLanes|=n;for(e=e.entanglements;t;){var...
  function Js (line 5) | function Js(e){return e&=-e,1<e?4<e?e&268435455?16:536870912:4:1}
  function Li (line 5) | function Li(e,n){switch(e){case"focusin":case"focusout":rn=null;break;ca...
  function pt (line 5) | function pt(e,n,t,r,l,o){return e===null||e.nativeEvent!==o?(e={blockedO...
  function Ff (line 5) | function Ff(e,n,t,r,l){switch(n){case"focusin":return rn=pt(rn,e,n,t,r,l...
  function ta (line 5) | function ta(e){var n=Sn(e.target);if(n!==null){var t=Rn(n);if(t!==null){...
  function Tr (line 5) | function Tr(e){if(e.blockedOn!==null)return!1;for(var n=e.targetContaine...
  function Ri (line 5) | function Ri(e,n,t){Tr(e)&&t.delete(n)}
  function jf (line 5) | function jf(){zo=!1,rn!==null&&Tr(rn)&&(rn=null),ln!==null&&Tr(ln)&&(ln=...
  function mt (line 5) | function mt(e,n){e.blockedOn===n&&(e.blockedOn=null,zo||(zo=!0,pe.unstab...
  function Ut (line 5) | function Ut(e){function n(l){return mt(l,e)}if(0<vr.length){mt(vr[0],e);...
  function Uf (line 5) | function Uf(e,n,t,r){var l=T,o=Zn.transition;Zn.transition=null;try{T=1,...
  function Vf (line 5) | function Vf(e,n,t,r){var l=T,o=Zn.transition;Zn.transition=null;try{T=4,...
  function pu (line 5) | function pu(e,n,t,r){if($r){var l=To(e,n,t,r);if(l===null)bl(e,n,r,Qr,t)...
  function To (line 5) | function To(e,n,t,r){if(Qr=null,e=au(r),e=Sn(e),e!==null)if(n=Rn(e),n===...
  function ra (line 5) | function ra(e){switch(e){case"cancel":case"click":case"close":case"conte...
  function la (line 5) | function la(){if(Lr)return Lr;var e,n=mu,t=n.length,r,l="value"in nn?nn....
  function Rr (line 5) | function Rr(e){var n=e.keyCode;return"charCode"in e?(e=e.charCode,e===0&...
  function hr (line 5) | function hr(){return!0}
  function Oi (line 5) | function Oi(){return!1}
  function me (line 5) | function me(e){function n(t,r,l,o,u){this._reactName=t,this._targetInst=...
  function qf (line 5) | function qf(e){var n=this.nativeEvent;return n.getModifierState?n.getMod...
  function hu (line 5) | function hu(){return qf}
  function ua (line 5) | function ua(e,n){switch(e){case"keyup":return sd.indexOf(n.keyCode)!==-1...
  function ia (line 5) | function ia(e){return e=e.detail,typeof e=="object"&&"data"in e?e.data:n...
  function cd (line 5) | function cd(e,n){switch(e){case"compositionend":return ia(n);case"keypre...
  function fd (line 5) | function fd(e,n){if(jn)return e==="compositionend"||!yu&&ua(e,n)?(e=la()...
  function Ui (line 5) | function Ui(e){var n=e&&e.nodeName&&e.nodeName.toLowerCase();return n===...
  function sa (line 5) | function sa(e,n,t,r){Vs(r),n=Kr(n,"onChange"),0<n.length&&(t=new vu("onC...
  function pd (line 5) | function pd(e){wa(e,0)}
  function fl (line 5) | function fl(e){var n=An(e);if(Os(n))return e}
  function md (line 5) | function md(e,n){if(e==="change")return n}
  function Vi (line 5) | function Vi(){Pt&&(Pt.detachEvent("onpropertychange",ca),Vt=Pt=null)}
  function ca (line 5) | function ca(e){if(e.propertyName==="value"&&fl(Vt)){var n=[];sa(n,Vt,e,a...
  function vd (line 5) | function vd(e,n,t){e==="focusin"?(Vi(),Pt=n,Vt=t,Pt.attachEvent("onprope...
  function hd (line 5) | function hd(e){if(e==="selectionchange"||e==="keyup"||e==="keydown")retu...
  function yd (line 5) | function yd(e,n){if(e==="click")return fl(n)}
  function gd (line 5) | function gd(e,n){if(e==="input"||e==="change")return fl(n)}
  function wd (line 5) | function wd(e,n){return e===n&&(e!==0||1/e===1/n)||e!==e&&n!==n}
  function At (line 5) | function At(e,n){if(Le(e,n))return!0;if(typeof e!="object"||e===null||ty...
  function Ai (line 5) | function Ai(e){for(;e&&e.firstChild;)e=e.firstChild;return e}
  function Hi (line 5) | function Hi(e,n){var t=Ai(e);e=0;for(var r;t;){if(t.nodeType===3){if(r=e...
  function fa (line 5) | function fa(e,n){return e&&n?e===n?!0:e&&e.nodeType===3?!1:n&&n.nodeType...
  function da (line 5) | function da(){for(var e=window,n=Vr();n instanceof e.HTMLIFrameElement;)...
  function gu (line 5) | function gu(e){var n=e&&e.nodeName&&e.nodeName.toLowerCase();return n&&(...
  function Sd (line 5) | function Sd(e){var n=da(),t=e.focusedElem,r=e.selectionRange;if(n!==t&&t...
  function Bi (line 5) | function Bi(e,n,t){var r=t.window===t?t.document:t.nodeType===9?t:t.owne...
  function wr (line 5) | function wr(e,n){var t={};return t[e.toLowerCase()]=n.toLowerCase(),t["W...
  function dl (line 5) | function dl(e){if(Jl[e])return Jl[e];if(!Vn[e])return e;var n=Vn[e],t;fo...
  function mn (line 5) | function mn(e,n){ga.set(e,n),Ln(n,[e])}
  function Ki (line 5) | function Ki(e,n,t){var r=e.type||"unknown-event";e.currentTarget=t,Ef(r,...
  function wa (line 5) | function wa(e,n){n=(n&4)!==0;for(var t=0;t<e.length;t++){var r=e[t],l=r....
  function O (line 5) | function O(e,n){var t=n[Fo];t===void 0&&(t=n[Fo]=new Set);var r=e+"__bub...
  function ql (line 5) | function ql(e,n,t){var r=0;n&&(r|=4),Sa(t,e,r,n)}
  function Ht (line 5) | function Ht(e){if(!e[Er]){e[Er]=!0,Ps.forEach(function(t){t!=="selection...
  function Sa (line 5) | function Sa(e,n,t,r){switch(ra(n)){case 1:var l=Uf;break;case 4:l=Vf;bre...
  function bl (line 5) | function bl(e,n,t,r,l){var o=r;if(!(n&1)&&!(n&2)&&r!==null)e:for(;;){if(...
  function Bt (line 5) | function Bt(e,n,t){return{instance:e,listener:n,currentTarget:t}}
  function Kr (line 5) | function Kr(e,n){for(var t=n+"Capture",r=[];e!==null;){var l=e,o=l.state...
  function Mn (line 5) | function Mn(e){if(e===null)return null;do e=e.return;while(e&&e.tag!==5)...
  function Yi (line 5) | function Yi(e,n,t,r,l){for(var o=n._reactName,u=[];t!==null&&t!==r;){var...
  function Xi (line 5) | function Xi(e){return(typeof e=="string"?e:""+e).replace(_d,`
  function _r (line 6) | function _r(e,n,t){if(n=Xi(n),Xi(e)!==n&&t)throw Error(h(425))}
  function Yr (line 6) | function Yr(){}
  function Mo (line 6) | function Mo(e,n){return e==="textarea"||e==="noscript"||typeof n.childre...
  function Pd (line 6) | function Pd(e){setTimeout(function(){throw e})}
  function eo (line 6) | function eo(e,n){var t=n,r=0;do{var l=t.nextSibling;if(e.removeChild(t),...
  function un (line 6) | function un(e){for(;e!=null;e=e.nextSibling){var n=e.nodeType;if(n===1||...
  function Zi (line 6) | function Zi(e){e=e.previousSibling;for(var n=0;e;){if(e.nodeType===8){va...
  function Sn (line 6) | function Sn(e){var n=e[Me];if(n)return n;for(var t=e.parentNode;t;){if(n...
  function qt (line 6) | function qt(e){return e=e[Me]||e[$e],!e||e.tag!==5&&e.tag!==6&&e.tag!==1...
  function An (line 6) | function An(e){if(e.tag===5||e.tag===6)return e.stateNode;throw Error(h(...
  function pl (line 6) | function pl(e){return e[Wt]||null}
  function vn (line 6) | function vn(e){return{current:e}}
  function D (line 6) | function D(e){0>Hn||(e.current=jo[Hn],jo[Hn]=null,Hn--)}
  function R (line 6) | function R(e,n){Hn++,jo[Hn]=e.current,e.current=n}
  function et (line 6) | function et(e,n){var t=e.type.contextTypes;if(!t)return pn;var r=e.state...
  function se (line 6) | function se(e){return e=e.childContextTypes,e!=null}
  function Xr (line 6) | function Xr(){D(ie),D(ee)}
  function Ji (line 6) | function Ji(e,n,t){if(ee.current!==pn)throw Error(h(168));R(ee,n),R(ie,t)}
  function ka (line 6) | function ka(e,n,t){var r=e.stateNode;if(n=n.childContextTypes,typeof r.g...
  function Gr (line 6) | function Gr(e){return e=(e=e.stateNode)&&e.__reactInternalMemoizedMerged...
  function qi (line 6) | function qi(e,n,t){var r=e.stateNode;if(!r)throw Error(h(169));t?(e=ka(e...
  function Ea (line 6) | function Ea(e){Ve===null?Ve=[e]:Ve.push(e)}
  function Ld (line 6) | function Ld(e){ml=!0,Ea(e)}
  function hn (line 6) | function hn(){if(!no&&Ve!==null){no=!0;var e=0,n=T;try{var t=Ve;for(T=1;...
  function gn (line 6) | function gn(e,n){Bn[Wn++]=Jr,Bn[Wn++]=Zr,Zr=e,Jr=n}
  function _a (line 6) | function _a(e,n,t){ye[ge++]=Ae,ye[ge++]=He,ye[ge++]=Nn,Nn=e;var r=Ae;e=H...
  function wu (line 6) | function wu(e){e.return!==null&&(gn(e,1),_a(e,1,0))}
  function Su (line 6) | function Su(e){for(;e===Zr;)Zr=Bn[--Wn],Bn[Wn]=null,Jr=Bn[--Wn],Bn[Wn]=n...
  function Ca (line 6) | function Ca(e,n){var t=we(5,null,null,0);t.elementType="DELETED",t.state...
  function bi (line 6) | function bi(e,n){switch(e.tag){case 5:var t=e.type;return n=n.nodeType!=...
  function Uo (line 6) | function Uo(e){return(e.mode&1)!==0&&(e.flags&128)===0}
  function Vo (line 6) | function Vo(e){if(M){var n=fe;if(n){var t=n;if(!bi(e,n)){if(Uo(e))throw ...
  function es (line 6) | function es(e){for(e=e.return;e!==null&&e.tag!==5&&e.tag!==3&&e.tag!==13...
  function Cr (line 6) | function Cr(e){if(e!==de)return!1;if(!M)return es(e),M=!0,!1;var n;if((n...
  function xa (line 6) | function xa(){for(var e=fe;e;)e=un(e.nextSibling)}
  function nt (line 6) | function nt(){fe=de=null,M=!1}
  function ku (line 6) | function ku(e){Pe===null?Pe=[e]:Pe.push(e)}
  function xe (line 6) | function xe(e,n){if(e&&e.defaultProps){n=j({},n),e=e.defaultProps;for(va...
  function _u (line 6) | function _u(){Eu=$n=br=null}
  function Cu (line 6) | function Cu(e){var n=qr.current;D(qr),e._currentValue=n}
  function Ao (line 6) | function Ao(e,n,t){for(;e!==null;){var r=e.alternate;if((e.childLanes&n)...
  function Jn (line 6) | function Jn(e,n){br=e,Eu=$n=null,e=e.dependencies,e!==null&&e.firstConte...
  function ke (line 6) | function ke(e){var n=e._currentValue;if(Eu!==e)if(e={context:e,memoizedV...
  function xu (line 6) | function xu(e){kn===null?kn=[e]:kn.push(e)}
  function Na (line 6) | function Na(e,n,t,r){var l=n.interleaved;return l===null?(t.next=t,xu(n)...
  function Qe (line 6) | function Qe(e,n){e.lanes|=n;var t=e.alternate;for(t!==null&&(t.lanes|=n)...
  function Nu (line 6) | function Nu(e){e.updateQueue={baseState:e.memoizedState,firstBaseUpdate:...
  function Pa (line 6) | function Pa(e,n){e=e.updateQueue,n.updateQueue===e&&(n.updateQueue={base...
  function Be (line 6) | function Be(e,n){return{eventTime:e,lane:n,tag:0,payload:null,callback:n...
  function sn (line 6) | function sn(e,n,t){var r=e.updateQueue;if(r===null)return null;if(r=r.sh...
  function Or (line 6) | function Or(e,n,t){if(n=n.updateQueue,n!==null&&(n=n.shared,(t&4194240)!...
  function ns (line 6) | function ns(e,n){var t=e.updateQueue,r=e.alternate;if(r!==null&&(r=r.upd...
  function el (line 6) | function el(e,n,t,r){var l=e.updateQueue;qe=!1;var o=l.firstBaseUpdate,u...
  function ts (line 6) | function ts(e,n,t){if(e=n.effects,n.effects=null,e!==null)for(n=0;n<e.le...
  function Ho (line 6) | function Ho(e,n,t,r){n=e.memoizedState,t=t(r,n),t=t==null?n:j({},n,t),e....
  function rs (line 6) | function rs(e,n,t,r,l,o,u){return e=e.stateNode,typeof e.shouldComponent...
  function Ta (line 6) | function Ta(e,n,t){var r=!1,l=pn,o=n.contextType;return typeof o=="objec...
  function ls (line 6) | function ls(e,n,t,r){e=n.state,typeof n.componentWillReceiveProps=="func...
  function Bo (line 6) | function Bo(e,n,t,r){var l=e.stateNode;l.props=t,l.state=e.memoizedState...
  function ht (line 6) | function ht(e,n,t){if(e=t.ref,e!==null&&typeof e!="function"&&typeof e!=...
  function xr (line 6) | function xr(e,n){throw e=Object.prototype.toString.call(n),Error(h(31,e=...
  function os (line 6) | function os(e){var n=e._init;return n(e._payload)}
  function La (line 6) | function La(e){function n(c,a){if(e){var d=c.deletions;d===null?(c.delet...
  function En (line 6) | function En(e){if(e===bt)throw Error(h(174));return e}
  function Pu (line 6) | function Pu(e,n){switch(R(Qt,n),R($t,e),R(Fe,bt),e=n.nodeType,e){case 9:...
  function rt (line 6) | function rt(){D(Fe),D($t),D(Qt)}
  function Oa (line 6) | function Oa(e){En(Qt.current);var n=En(Fe.current),t=So(n,e.type);n!==t&...
  function zu (line 6) | function zu(e){$t.current===e&&(D(Fe),D($t))}
  function nl (line 6) | function nl(e){for(var n=e;n!==null;){if(n.tag===13){var t=n.memoizedSta...
  function Tu (line 6) | function Tu(){for(var e=0;e<to.length;e++)to[e]._workInProgressVersionPr...
  function J (line 6) | function J(){throw Error(h(321))}
  function Lu (line 6) | function Lu(e,n){if(n===null)return!1;for(var t=0;t<n.length&&t<e.length...
  function Ru (line 6) | function Ru(e,n,t,r,l,o){if(Pn=o,F=n,n.memoizedState=null,n.updateQueue=...
  function Ou (line 6) | function Ou(){var e=Kt!==0;return Kt=0,e}
  function De (line 6) | function De(){var e={memoizedState:null,baseState:null,baseQueue:null,qu...
  function Ee (line 6) | function Ee(){if(B===null){var e=F.alternate;e=e!==null?e.memoizedState:...
  function Yt (line 6) | function Yt(e,n){return typeof n=="function"?n(e):n}
  function lo (line 6) | function lo(e){var n=Ee(),t=n.queue;if(t===null)throw Error(h(311));t.la...
  function oo (line 6) | function oo(e){var n=Ee(),t=n.queue;if(t===null)throw Error(h(311));t.la...
  function Da (line 6) | function Da(){}
  function Ma (line 6) | function Ma(e,n){var t=F,r=Ee(),l=n(),o=!Le(r.memoizedState,l);if(o&&(r....
  function Ia (line 6) | function Ia(e,n,t){e.flags|=16384,e={getSnapshot:n,value:t},n=F.updateQu...
  function Fa (line 6) | function Fa(e,n,t,r){n.value=t,n.getSnapshot=r,Ua(n)&&Va(e)}
  function ja (line 6) | function ja(e,n,t){return t(function(){Ua(n)&&Va(e)})}
  function Ua (line 6) | function Ua(e){var n=e.getSnapshot;e=e.value;try{var t=n();return!Le(e,t...
  function Va (line 6) | function Va(e){var n=Qe(e,1);n!==null&&Te(n,e,1,-1)}
  function us (line 6) | function us(e){var n=De();return typeof e=="function"&&(e=e()),n.memoize...
  function Xt (line 6) | function Xt(e,n,t,r){return e={tag:e,create:n,destroy:t,deps:r,next:null...
  function Aa (line 6) | function Aa(){return Ee().memoizedState}
  function Mr (line 6) | function Mr(e,n,t,r){var l=De();F.flags|=e,l.memoizedState=Xt(1|n,t,void...
  function hl (line 6) | function hl(e,n,t,r){var l=Ee();r=r===void 0?null:r;var o=void 0;if(B!==...
  function is (line 6) | function is(e,n){return Mr(8390656,8,e,n)}
  function Du (line 6) | function Du(e,n){return hl(2048,8,e,n)}
  function Ha (line 6) | function Ha(e,n){return hl(4,2,e,n)}
  function Ba (line 6) | function Ba(e,n){return hl(4,4,e,n)}
  function Wa (line 6) | function Wa(e,n){if(typeof n=="function")return e=e(),n(e),function(){n(...
  function $a (line 6) | function $a(e,n,t){return t=t!=null?t.concat([e]):null,hl(4,4,Wa.bind(nu...
  function Mu (line 6) | function Mu(){}
  function Qa (line 6) | function Qa(e,n){var t=Ee();n=n===void 0?null:n;var r=t.memoizedState;re...
  function Ka (line 6) | function Ka(e,n){var t=Ee();n=n===void 0?null:n;var r=t.memoizedState;re...
  function Ya (line 6) | function Ya(e,n,t){return Pn&21?(Le(t,n)||(t=Zs(),F.lanes|=t,zn|=t,e.bas...
  function Dd (line 6) | function Dd(e,n){var t=T;T=t!==0&&4>t?t:4,e(!0);var r=ro.transition;ro.t...
  function Xa (line 6) | function Xa(){return Ee().memoizedState}
  function Md (line 6) | function Md(e,n,t){var r=cn(e);if(t={lane:r,action:t,hasEagerState:!1,ea...
  function Id (line 6) | function Id(e,n,t){var r=cn(e),l={lane:r,action:t,hasEagerState:!1,eager...
  function Ga (line 6) | function Ga(e){var n=e.alternate;return e===F||n!==null&&n===F}
  function Za (line 6) | function Za(e,n){Tt=tl=!0;var t=e.pending;t===null?n.next=n:(n.next=t.ne...
  function Ja (line 6) | function Ja(e,n,t){if(t&4194240){var r=n.lanes;r&=e.pendingLanes,t|=r,n....
  function lt (line 6) | function lt(e,n){try{var t="",r=n;do t+=mf(r),r=r.return;while(r);var l=...
  function uo (line 8) | function uo(e,n,t){return{value:e,source:null,stack:t??null,digest:n??nu...
  function Wo (line 8) | function Wo(e,n){try{console.error(n.value)}catch(t){setTimeout(function...
  function qa (line 8) | function qa(e,n,t){t=Be(-1,t),t.tag=3,t.payload={element:null};var r=n.v...
  function ba (line 8) | function ba(e,n,t){t=Be(-1,t),t.tag=3;var r=e.type.getDerivedStateFromEr...
  function ss (line 8) | function ss(e,n,t){var r=e.pingCache;if(r===null){r=e.pingCache=new Vd;v...
  function as (line 8) | function as(e){do{var n;if((n=e.tag===13)&&(n=e.memoizedState,n=n!==null...
  function cs (line 8) | function cs(e,n,t,r,l){return e.mode&1?(e.flags|=65536,e.lanes=l,e):(e==...
  function te (line 8) | function te(e,n,t,r){n.child=e===null?Ra(n,null,t,r):tt(n,e.child,t,r)}
  function fs (line 8) | function fs(e,n,t,r,l){t=t.render;var o=n.ref;return Jn(n,l),r=Ru(e,n,t,...
  function ds (line 8) | function ds(e,n,t,r,l){if(e===null){var o=t.type;return typeof o=="funct...
  function ec (line 8) | function ec(e,n,t,r,l){if(e!==null){var o=e.memoizedProps;if(At(o,r)&&e....
  function nc (line 8) | function nc(e,n,t){var r=n.pendingProps,l=r.children,o=e!==null?e.memoiz...
  function tc (line 8) | function tc(e,n){var t=n.ref;(e===null&&t!==null||e!==null&&e.ref!==t)&&...
  function $o (line 8) | function $o(e,n,t,r,l){var o=se(t)?xn:ee.current;return o=et(n,o),Jn(n,l...
  function ps (line 8) | function ps(e,n,t,r,l){if(se(t)){var o=!0;Gr(n)}else o=!1;if(Jn(n,l),n.s...
  function Qo (line 8) | function Qo(e,n,t,r,l,o){tc(e,n);var u=(n.flags&128)!==0;if(!r&&!u)retur...
  function rc (line 8) | function rc(e){var n=e.stateNode;n.pendingContext?Ji(e,n.pendingContext,...
  function ms (line 8) | function ms(e,n,t,r,l){return nt(),ku(l),n.flags|=256,te(e,n,t,r),n.child}
  function Yo (line 8) | function Yo(e){return{baseLanes:e,cachePool:null,transitions:null}}
  function lc (line 8) | function lc(e,n,t){var r=n.pendingProps,l=I.current,o=!1,u=(n.flags&128)...
  function Iu (line 8) | function Iu(e,n){return n=wl({mode:"visible",children:n},e.mode,0,null),...
  function Nr (line 8) | function Nr(e,n,t,r){return r!==null&&ku(r),tt(n,e.child,null,t),e=Iu(n,...
  function Hd (line 8) | function Hd(e,n,t,r,l,o,u){if(t)return n.flags&256?(n.flags&=-257,r=uo(E...
  function vs (line 8) | function vs(e,n,t){e.lanes|=n;var r=e.alternate;r!==null&&(r.lanes|=n),A...
  function io (line 8) | function io(e,n,t,r,l){var o=e.memoizedState;o===null?e.memoizedState={i...
  function oc (line 8) | function oc(e,n,t){var r=n.pendingProps,l=r.revealOrder,o=r.tail;if(te(e...
  function Ir (line 8) | function Ir(e,n){!(n.mode&1)&&e!==null&&(e.alternate=null,n.alternate=nu...
  function Ke (line 8) | function Ke(e,n,t){if(e!==null&&(n.dependencies=e.dependencies),zn|=n.la...
  function Bd (line 8) | function Bd(e,n,t){switch(n.tag){case 3:rc(n),nt();break;case 5:Oa(n);br...
  function yt (line 8) | function yt(e,n){if(!M)switch(e.tailMode){case"hidden":n=e.tail;for(var ...
  function q (line 8) | function q(e){var n=e.alternate!==null&&e.alternate.child===e.child,t=0,...
  function Wd (line 8) | function Wd(e,n,t){var r=n.pendingProps;switch(Su(n),n.tag){case 2:case ...
  function $d (line 8) | function $d(e,n){switch(Su(n),n.tag){case 1:return se(n.type)&&Xr(),e=n....
  function Qn (line 8) | function Qn(e,n){var t=e.ref;if(t!==null)if(typeof t=="function")try{t(n...
  function Go (line 8) | function Go(e,n,t){try{t()}catch(r){U(e,n,r)}}
  function Kd (line 8) | function Kd(e,n){if(Oo=$r,e=da(),gu(e)){if("selectionStart"in e)var t={s...
  function Lt (line 8) | function Lt(e,n,t){var r=n.updateQueue;if(r=r!==null?r.lastEffect:null,r...
  function yl (line 8) | function yl(e,n){if(n=n.updateQueue,n=n!==null?n.lastEffect:null,n!==nul...
  function Zo (line 8) | function Zo(e){var n=e.ref;if(n!==null){var t=e.stateNode;switch(e.tag){...
  function ac (line 8) | function ac(e){var n=e.alternate;n!==null&&(e.alternate=null,ac(n)),e.ch...
  function cc (line 8) | function cc(e){return e.tag===5||e.tag===3||e.tag===4}
  function ys (line 8) | function ys(e){e:for(;;){for(;e.sibling===null;){if(e.return===null||cc(...
  function Jo (line 8) | function Jo(e,n,t){var r=e.tag;if(r===5||r===6)e=e.stateNode,n?t.nodeTyp...
  function qo (line 8) | function qo(e,n,t){var r=e.tag;if(r===5||r===6)e=e.stateNode,n?t.insertB...
  function Ze (line 8) | function Ze(e,n,t){for(t=t.child;t!==null;)fc(e,n,t),t=t.sibling}
  function fc (line 8) | function fc(e,n,t){if(Ie&&typeof Ie.onCommitFiberUnmount=="function")try...
  function gs (line 8) | function gs(e){var n=e.updateQueue;if(n!==null){e.updateQueue=null;var t...
  function Ce (line 8) | function Ce(e,n){var t=n.deletions;if(t!==null)for(var r=0;r<t.length;r+...
  function dc (line 8) | function dc(e,n){var t=e.alternate,r=e.flags;switch(e.tag){case 0:case 1...
  function Oe (line 8) | function Oe(e){var n=e.flags;if(n&2){try{e:{for(var t=e.return;t!==null;...
  function Yd (line 8) | function Yd(e,n,t){w=e,pc(e,n,t)}
  function pc (line 8) | function pc(e,n,t){for(var r=(e.mode&1)!==0;w!==null;){var l=w,o=l.child...
  function ws (line 8) | function ws(e){for(;w!==null;){var n=w;if(n.flags&8772){var t=n.alternat...
  function Ss (line 8) | function Ss(e){for(;w!==null;){var n=w;if(n===e){w=null;break}var t=n.si...
  function ks (line 8) | function ks(e){for(;w!==null;){var n=w;try{switch(n.tag){case 0:case 11:...
  function re (line 8) | function re(){return P&6?A():Fr!==-1?Fr:Fr=A()}
  function cn (line 8) | function cn(e){return e.mode&1?P&2&&X!==0?X&-X:Rd.transition!==null?(jr=...
  function Te (line 8) | function Te(e,n,t,r){if(50<Ot)throw Ot=0,eu=null,Error(h(185));Zt(e,t,r)...
  function ae (line 8) | function ae(e,n){var t=e.callbackNode;Df(e,n);var r=Wr(e,e===K?X:0);if(r...
  function mc (line 8) | function mc(e,n){if(Fr=-1,jr=0,P&6)throw Error(h(327));var t=e.callbackN...
  function nu (line 8) | function nu(e,n){var t=Rt;return e.current.memoizedState.isDehydrated&&(...
  function tu (line 8) | function tu(e){oe===null?oe=e:oe.push.apply(oe,e)}
  function Gd (line 8) | function Gd(e){for(var n=e;;){if(n.flags&16384){var t=n.updateQueue;if(t...
  function en (line 8) | function en(e,n){for(n&=~ju,n&=~gl,e.suspendedLanes|=n,e.pingedLanes&=~n...
  function Es (line 8) | function Es(e){if(P&6)throw Error(h(327));qn();var n=Wr(e,0);if(!(n&1))r...
  function Vu (line 8) | function Vu(e,n){var t=P;P|=1;try{return e(n)}finally{P=t,P===0&&(ot=A()...
  function Tn (line 8) | function Tn(e){tn!==null&&tn.tag===0&&!(P&6)&&qn();var n=P;P|=1;var t=Se...
  function Au (line 8) | function Au(){ce=Kn.current,D(Kn)}
  function _n (line 8) | function _n(e,n){e.finishedWork=null,e.finishedLanes=0;var t=e.timeoutHa...
  function vc (line 8) | function vc(e,n){do{var t=H;try{if(_u(),Dr.current=rl,tl){for(var r=F.me...
  function hc (line 8) | function hc(){var e=ll.current;return ll.current=rl,e===null?rl:e}
  function Hu (line 8) | function Hu(){(W===0||W===3||W===2)&&(W=4),K===null||!(zn&268435455)&&!(...
  function il (line 8) | function il(e,n){var t=P;P|=2;var r=hc();(K!==e||X!==n)&&(Ue=null,_n(e,n...
  function Zd (line 8) | function Zd(){for(;H!==null;)yc(H)}
  function Jd (line 8) | function Jd(){for(;H!==null&&!Cf();)yc(H)}
  function yc (line 8) | function yc(e){var n=Sc(e.alternate,e,ce);e.memoizedProps=e.pendingProps...
  function gc (line 8) | function gc(e){var n=e;do{var t=n.alternate;if(e=n.return,n.flags&32768)...
  function wn (line 8) | function wn(e,n,t){var r=T,l=Se.transition;try{Se.transition=null,T=1,qd...
  function qd (line 8) | function qd(e,n,t,r){do qn();while(tn!==null);if(P&6)throw Error(h(327))...
  function qn (line 8) | function qn(){if(tn!==null){var e=Js(ul),n=Se.transition,t=T;try{if(Se.t...
  function _s (line 8) | function _s(e,n,t){n=lt(t,n),n=qa(e,n,1),e=sn(e,n,1),n=re(),e!==null&&(Z...
  function U (line 8) | function U(e,n,t){if(e.tag===3)_s(e,e,t);else for(;n!==null;){if(n.tag==...
  function bd (line 8) | function bd(e,n,t){var r=e.pingCache;r!==null&&r.delete(n),n=re(),e.ping...
  function wc (line 8) | function wc(e,n){n===0&&(e.mode&1?(n=mr,mr<<=1,!(mr&130023424)&&(mr=4194...
  function ep (line 8) | function ep(e){var n=e.memoizedState,t=0;n!==null&&(t=n.retryLane),wc(e,t)}
  function np (line 8) | function np(e,n){var t=0;switch(e.tag){case 13:var r=e.stateNode,l=e.mem...
  function kc (line 8) | function kc(e,n){return Ys(e,n)}
  function tp (line 8) | function tp(e,n,t,r){this.tag=e,this.key=t,this.sibling=this.child=this....
  function we (line 8) | function we(e,n,t,r){return new tp(e,n,t,r)}
  function Bu (line 8) | function Bu(e){return e=e.prototype,!(!e||!e.isReactComponent)}
  function rp (line 8) | function rp(e){if(typeof e=="function")return Bu(e)?1:0;if(e!=null){if(e...
  function fn (line 8) | function fn(e,n){var t=e.alternate;return t===null?(t=we(e.tag,n,e.key,e...
  function Ur (line 8) | function Ur(e,n,t,r,l,o){var u=2;if(r=e,typeof e=="function")Bu(e)&&(u=1...
  function Cn (line 8) | function Cn(e,n,t,r){return e=we(7,e,r,n),e.lanes=t,e}
  function wl (line 8) | function wl(e,n,t,r){return e=we(22,e,r,n),e.elementType=Ls,e.lanes=t,e....
  function so (line 8) | function so(e,n,t){return e=we(6,e,null,n),e.lanes=t,e}
  function ao (line 8) | function ao(e,n,t){return n=we(4,e.children!==null?e.children:[],e.key,n...
  function lp (line 8) | function lp(e,n,t,r,l){this.tag=n,this.containerInfo=e,this.finishedWork...
  function Wu (line 8) | function Wu(e,n,t,r,l,o,u,i,s){return e=new lp(e,n,t,i,s),n===1?(n=1,o==...
  function op (line 8) | function op(e,n,t){var r=3<arguments.length&&arguments[3]!==void 0?argum...
  function Ec (line 8) | function Ec(e){if(!e)return pn;e=e._reactInternals;e:{if(Rn(e)!==e||e.ta...
  function _c (line 8) | function _c(e,n,t,r,l,o,u,i,s){return e=Wu(t,r,!0,e,l,o,u,i,s),e.context...
  function Sl (line 8) | function Sl(e,n,t,r){var l=n.current,o=re(),u=cn(l);return t=Ec(t),n.con...
  function sl (line 8) | function sl(e){if(e=e.current,!e.child)return null;switch(e.child.tag){c...
  function Cs (line 8) | function Cs(e,n){if(e=e.memoizedState,e!==null&&e.dehydrated!==null){var...
  function $u (line 8) | function $u(e,n){Cs(e,n),(e=e.alternate)&&Cs(e,n)}
  function up (line 8) | function up(){return null}
  function Qu (line 8) | function Qu(e){this._internalRoot=e}
  function kl (line 8) | function kl(e){this._internalRoot=e}
  function Ku (line 8) | function Ku(e){return!(!e||e.nodeType!==1&&e.nodeType!==9&&e.nodeType!==...
  function El (line 8) | function El(e){return!(!e||e.nodeType!==1&&e.nodeType!==9&&e.nodeType!==...
  function xs (line 8) | function xs(){}
  function ip (line 8) | function ip(e,n,t,r,l){if(l){if(typeof r=="function"){var o=r;r=function...
  function _l (line 8) | function _l(e,n,t,r,l){var o=t._reactRootContainer;if(o){var u=o;if(type...
  function Nc (line 8) | function Nc(){if(!(typeof __REACT_DEVTOOLS_GLOBAL_HOOK__>"u"||typeof __R...
  function Rc (line 8) | function Rc(e,n,t){var r,l={},o=null,u=null;t!==void 0&&(o=""+t),n.key!=...
  function gp (line 8) | function gp(e){let n=e.getAttribute("data-name")??"";(0,xl.createRoot)(e...

FILE: examples/internationalization/components_templ.go
  function page (line 12) | func page() templ.Component {

FILE: examples/internationalization/main.go
  function newLanguageMiddleware (line 13) | func newLanguageMiddleware(next http.Handler) http.Handler {
  function main (line 30) | func main() {

FILE: examples/static-generator/blog_templ.go
  function headerComponent (line 15) | func headerComponent(title string) templ.Component {
  function contentComponent (line 57) | func contentComponent(title string, body templ.Component) templ.Component {
  function contentPage (line 107) | func contentPage(title string, body templ.Component) templ.Component {
  function indexPage (line 148) | func indexPage(posts []Post) templ.Component {

FILE: examples/static-generator/main.go
  type Post (line 17) | type Post struct
  function Unsafe (line 23) | func Unsafe(html string) templ.Component {
  function main (line 30) | func main() {

FILE: examples/streaming/main_templ.go
  function main (line 16) | func main() {
  function Page (line 45) | func Page(data chan string) templ.Component {

FILE: examples/suspense/main_templ.go
  function main (line 16) | func main() {
  type SlotContents (line 71) | type SlotContents struct
  function Slot (line 76) | func Slot(name string) templ.Component {
  function A (line 131) | func A() templ.Component {
  function B (line 160) | func B() templ.Component {
  function C (line 189) | func C() templ.Component {
  function Page (line 218) | func Page(data chan SlotContents) templ.Component {

FILE: examples/syntax-and-usage/components/main.go
  function main (line 14) | func main() {
  function codeList (line 24) | func codeList(items []string) templ.Component {

FILE: examples/syntax-and-usage/components/templsyntax_templ.go
  function list (line 10) | func list(items []string) templ.Component {

FILE: examples/typescript/assets/js/index.js
  function a (line 1) | function a(){let t=document.querySelector("#attributeAlerter");t&&t.addE...
  function c (line 1) | function c(){let t=document.querySelector("#scriptAlerter");t&&t.addEven...

FILE: examples/typescript/components/index_templ.go
  type Data (line 10) | type Data struct
  function Page (line 14) | func Page(attributeData Data, scriptData Data) templ.Component {

FILE: examples/typescript/main.go
  function main (line 11) | func main() {

FILE: examples/typescript/ts/src/index.ts
  type Data (line 5) | interface Data {
  function setupAttributeAlerter (line 9) | function setupAttributeAlerter() {
  function setupScriptAlerter (line 21) | function setupScriptAlerter() {

FILE: flush.go
  function Flush (line 9) | func Flush() FlushComponent {
  type FlushComponent (line 13) | type FlushComponent struct
    method Render (line 24) | func (f FlushComponent) Render(ctx context.Context, w io.Writer) (err ...
  type flusherError (line 16) | type flusherError interface
  type flusher (line 20) | type flusher interface

FILE: flush_test.go
  type flushableErrorWriter (line 11) | type flushableErrorWriter struct
    method Write (line 18) | func (f *flushableErrorWriter) Write(p []byte) (n int, err error) {
    method Flush (line 30) | func (f *flushableErrorWriter) Flush() error {
  type flushableWriter (line 36) | type flushableWriter struct
    method Write (line 43) | func (f *flushableWriter) Write(p []byte) (n int, err error) {
    method Flush (line 55) | func (f *flushableWriter) Flush() {
  function TestFlush (line 60) | func TestFlush(t *testing.T) {

FILE: fragment.go
  function RenderFragments (line 10) | func RenderFragments(ctx context.Context, w io.Writer, c Component, ids ...
  type fragmentContextKeyType (line 18) | type fragmentContextKeyType
  constant fragmentContextKey (line 20) | fragmentContextKey fragmentContextKeyType = iota
  type FragmentContext (line 23) | type FragmentContext struct
  function Fragment (line 32) | func Fragment(id any) Component {
  type fragment (line 38) | type fragment struct
    method Render (line 42) | func (f *fragment) Render(ctx context.Context, w io.Writer) (err error) {
  function getFragmentContext (line 60) | func getFragmentContext(ctx context.Context) *FragmentContext {

FILE: fragment_test.go
  function TestFragment (line 12) | func TestFragment(t *testing.T) {

FILE: generator/generator.go
  type GenerateOpt (line 22) | type GenerateOpt
  function WithVersion (line 25) | func WithVersion(v string) GenerateOpt {
  function WithTimestamp (line 33) | func WithTimestamp(d time.Time) GenerateOpt {
  function WithFileName (line 41) | func WithFileName(name string) GenerateOpt {
  function WithSkipCodeGeneratedComment (line 55) | func WithSkipCodeGeneratedComment() GenerateOpt {
  type GeneratorOutput (line 62) | type GeneratorOutput struct
  type GeneratorOptions (line 68) | type GeneratorOptions struct
  function HasGoChanged (line 80) | func HasGoChanged(previous, updated GeneratorOutput) bool {
  function HasTextChanged (line 109) | func HasTextChanged(previous, updated GeneratorOutput) bool {
  function Generate (line 123) | func Generate(template *parser.TemplateFile, w io.Writer, opts ...Genera...
  type generator (line 144) | type generator struct
    method generate (line 154) | func (g *generator) generate() (err error) {
    method writeCodeGeneratedComment (line 185) | func (g *generator) writeCodeGeneratedComment() (err error) {
    method writeVersionComment (line 195) | func (g *generator) writeVersionComment() (err error) {
    method writeGeneratedDateComment (line 202) | func (g *generator) writeGeneratedDateComment() (err error) {
    method writeHeader (line 209) | func (g *generator) writeHeader() (err error) {
    method writePackage (line 221) | func (g *generator) writePackage() error {
    method writeImports (line 235) | func (g *generator) writeImports() error {
    method writeTemplateNodes (line 250) | func (g *generator) writeTemplateNodes() error {
    method writeCSS (line 276) | func (g *generator) writeCSS(n *parser.CSSTemplate) error {
    method writeGoExpression (line 363) | func (g *generator) writeGoExpression(n *parser.TemplateFileGoExpressi...
    method writeTemplBuffer (line 395) | func (g *generator) writeTemplBuffer(indentLevel int) (err error) {
    method writeTemplate (line 447) | func (g *generator) writeTemplate(nodeIdx int, t *parser.HTMLTemplate)...
    method writeNodes (line 592) | func (g *generator) writeNodes(indentLevel int, nodes []parser.Node, n...
    method writeNode (line 608) | func (g *generator) writeNode(indentLevel int, current parser.Node, ne...
    method writeWhitespaceTrailer (line 683) | func (g *generator) writeWhitespaceTrailer(indentLevel int, n parser.T...
    method writeDocType (line 698) | func (g *generator) writeDocType(indentLevel int, n *parser.DocType) (...
    method writeFallthrough (line 705) | func (g *generator) writeFallthrough(indentLevel int) (err error) {
    method writeIfExpression (line 715) | func (g *generator) writeIfExpression(indentLevel int, n *parser.IfExp...
    method writeSwitchExpression (line 779) | func (g *generator) writeSwitchExpression(indentLevel int, n *parser.S...
    method writeChildrenExpression (line 817) | func (g *generator) writeChildrenExpression(indentLevel int) (err erro...
    method writeTemplElementExpression (line 827) | func (g *generator) writeTemplElementExpression(indentLevel int, n *pa...
    method writeBlockTemplElementExpression (line 834) | func (g *generator) writeBlockTemplElementExpression(indentLevel int, ...
    method writeSelfClosingTemplElementExpression (line 879) | func (g *generator) writeSelfClosingTemplElementExpression(indentLevel...
    method writeCallTemplateExpression (line 899) | func (g *generator) writeCallTemplateExpression(indentLevel int, n *pa...
    method writeForExpression (line 919) | func (g *generator) writeForExpression(indentLevel int, n *parser.ForE...
    method writeErrorHandler (line 947) | func (g *generator) writeErrorHandler(indentLevel int) (err error) {
    method writeExpressionErrorHandler (line 965) | func (g *generator) writeExpressionErrorHandler(indentLevel int, expre...
    method writeElement (line 985) | func (g *generator) writeElement(indentLevel int, n *parser.Element) (...
    method writeAttributeCSS (line 1028) | func (g *generator) writeAttributeCSS(indentLevel int, attr *parser.Ex...
    method writeAttributesCSS (line 1069) | func (g *generator) writeAttributesCSS(indentLevel int, attrs []parser...
    method writeElementCSS (line 1095) | func (g *generator) writeElementCSS(indentLevel int, attrs []parser.At...
    method writeElementScript (line 1108) | func (g *generator) writeElementScript(indentLevel int, attrs []parser...
    method writeAttributeKey (line 1145) | func (g *generator) writeAttributeKey(indentLevel int, attr parser.Att...
    method writeBoolConstantAttribute (line 1188) | func (g *generator) writeBoolConstantAttribute(indentLevel int, attr *...
    method writeConstantAttribute (line 1192) | func (g *generator) writeConstantAttribute(indentLevel int, attr *pars...
    method writeBoolExpressionAttribute (line 1214) | func (g *generator) writeBoolExpressionAttribute(indentLevel int, attr...
    method writeExpressionAttributeValueURL (line 1243) | func (g *generator) writeExpressionAttributeValueURL(indentLevel int, ...
    method writeExpressionAttributeValueScript (line 1275) | func (g *generator) writeExpressionAttributeValueScript(indentLevel in...
    method writeExpressionAttributeValueDefault (line 1297) | func (g *generator) writeExpressionAttributeValueDefault(indentLevel i...
    method writeExpressionAttributeValueStyle (line 1330) | func (g *generator) writeExpressionAttributeValueStyle(indentLevel int...
    method writeExpressionAttribute (line 1363) | func (g *generator) writeExpressionAttribute(indentLevel int, elementN...
    method writeSpreadAttributes (line 1397) | func (g *generator) writeSpreadAttributes(indentLevel int, attr *parse...
    method writeConditionalAttribute (line 1418) | func (g *generator) writeConditionalAttribute(indentLevel int, element...
    method writeElementAttributes (line 1460) | func (g *generator) writeElementAttributes(indentLevel int, name strin...
    method writeRawElement (line 1482) | func (g *generator) writeRawElement(indentLevel int, n *parser.RawElem...
    method writeScriptElement (line 1516) | func (g *generator) writeScriptElement(indentLevel int, n *parser.Scri...
    method writeScriptContents (line 1552) | func (g *generator) writeScriptContents(indentLevel int, c parser.Scri...
    method writeComment (line 1610) | func (g *generator) writeComment(indentLevel int, c *parser.HTMLCommen...
    method createVariableName (line 1626) | func (g *generator) createVariableName() string {
    method writeGoCode (line 1631) | func (g *generator) writeGoCode(indentLevel int, e parser.Expression) ...
    method writeStringExpression (line 1643) | func (g *generator) writeStringExpression(indentLevel int, e parser.Ex...
    method writeWhitespace (line 1683) | func (g *generator) writeWhitespace(indentLevel int, n *parser.Whitesp...
    method writeText (line 1694) | func (g *generator) writeText(indentLevel int, n *parser.Text) (err er...
    method writeScript (line 1713) | func (g *generator) writeScript(t *parser.ScriptTemplate) error {
    method writeBlankAssignmentForRuntimeImport (line 1794) | func (g *generator) writeBlankAssignmentForRuntimeImport() error {
  function stripWhitespace (line 560) | func stripWhitespace(input []parser.Node) (output []parser.Node) {
  function stripLeadingWhitespace (line 569) | func stripLeadingWhitespace(nodes []parser.Node) []parser.Node {
  function stripTrailingWhitespace (line 578) | func stripTrailingWhitespace(nodes []parser.Node) []parser.Node {
  function stripLeadingAndTrailingWhitespace (line 588) | func stripLeadingAndTrailingWhitespace(nodes []parser.Node) []parser.Node {
  function isInlineOrText (line 660) | func isInlineOrText(next parser.Node) bool {
  function escapeQuotes (line 710) | func escapeQuotes(s string) string {
  function isScriptAttribute (line 1099) | func isScriptAttribute(name string) bool {
  function getAttributeScripts (line 1127) | func getAttributeScripts(attr parser.Attribute) (scripts []string) {
  function createGoString (line 1699) | func createGoString(s string) string {
  function functionName (line 1802) | func functionName(name string, body string) string {
  function stripTypes (line 1809) | func stripTypes(parameters string) string {
  function isExpressionAttributeValueURL (line 1819) | func isExpressionAttributeValueURL(elementName, attrName string) bool {

FILE: generator/generator_test.go
  function TestGeneratorSourceMap (line 11) | func TestGeneratorSourceMap(t *testing.T) {
  function TestGeneratorForLSP (line 51) | func TestGeneratorForLSP(t *testing.T) {
  function TestIsExpressionAttributeValueURL (line 74) | func TestIsExpressionAttributeValueURL(t *testing.T) {

FILE: generator/htmldiff/diff.go
  function DiffStrings (line 14) | func DiffStrings(expected, actual string) (output, diff string, err erro...
  function Diff (line 44) | func Diff(input templ.Component, expected string) (actual, diff string, ...
  function DiffCtx (line 48) | func DiffCtx(ctx context.Context, input templ.Component, expected string...

FILE: generator/rangewriter.go
  function NewRangeWriter (line 12) | func NewRangeWriter(w io.Writer) *RangeWriter {
  type RangeWriter (line 19) | type RangeWriter struct
    method closeLiteral (line 30) | func (rw *RangeWriter) closeLiteral(indent int) (r parser.Range, err e...
    method WriteIndent (line 54) | func (rw *RangeWriter) WriteIndent(level int, s string) (r parser.Rang...
    method WriteStringLiteral (line 67) | func (rw *RangeWriter) WriteStringLiteral(level int, s string) (r pars...
    method Write (line 73) | func (rw *RangeWriter) Write(s string) (r parser.Range, err error) {
    method write (line 82) | func (rw *RangeWriter) write(s string) (r parser.Range, err error) {
    method writeErrorHandler (line 106) | func (rw *RangeWriter) writeErrorHandler(indentLevel int) (err error) {

FILE: generator/rangewriter_test.go
  function TestRangeWriter (line 11) | func TestRangeWriter(t *testing.T) {

FILE: generator/test-a-href/render_test.go
  function Test (line 14) | func Test(t *testing.T) {

FILE: generator/test-a-href/template_templ.go
  function render (line 10) | func render() templ.Component {

FILE: generator/test-attribute-errors/render_test.go
  function Test (line 17) | func Test(t *testing.T) {

FILE: generator/test-attribute-errors/template_templ.go
  function funcWithNoError (line 10) | func funcWithNoError() (s string) {
  function funcWithError (line 14) | func funcWithError(in error) (s string, err error) {
  function TestComponent (line 21) | func TestComponent(err error) templ.Component {

FILE: generator/test-attribute-escaping/render_test.go
  function Test (line 15) | func Test(t *testing.T) {

FILE: generator/test-attribute-escaping/template_templ.go
  function BasicTemplate (line 10) | func BasicTemplate(url string) templ.Component {

FILE: generator/test-call/render_test.go
  function Test (line 14) | func Test(t *testing.T) {

FILE: generator/test-call/template_templ.go
  function showAll (line 10) | func showAll() templ.Component {
  function a (line 73) | func a() templ.Component {
  function b (line 102) | func b(child templ.Component) templ.Component {
  function c (line 135) | func c(text string) templ.Component {
  function d (line 177) | func d() templ.Component {
  function e (line 206) | func e() templ.Component {
  function showOne (line 235) | func showOne(component templ.Component) templ.Component {
  function wrapChildren (line 272) | func wrapChildren() templ.Component {

FILE: generator/test-cancelled-context/render_test.go
  function Test (line 9) | func Test(t *testing.T) {

FILE: generator/test-cancelled-context/template_templ.go
  function EmptyComponent (line 10) | func EmptyComponent() templ.Component {

FILE: generator/test-class-whitespace/render_test.go
  function Test (line 14) | func Test(t *testing.T) {

FILE: generator/test-class-whitespace/template_templ.go
  function MultilineClassAttribute (line 11) | func MultilineClassAttribute() templ.Component {
  function ExtraSpaces (line 40) | func ExtraSpaces() templ.Component {
  function LeadingTrailingSpaces (line 69) | func LeadingTrailingSpaces() templ.Component {
  function TabsAndNewlines (line 98) | func TabsAndNewlines() templ.Component {
  function CaseInsensitive (line 127) | func CaseInsensitive() templ.Component {
  function OtherAttributesUnchanged (line 156) | func OtherAttributesUnchanged() templ.Component {
  function TestComponent (line 185) | func TestComponent() templ.Component {

FILE: generator/test-complex-attributes/render_test.go
  function Test (line 15) | func Test(t *testing.T) {

FILE: generator/test-complex-attributes/template_templ.go
  function ComplexAttributes (line 10) | func ComplexAttributes() templ.Component {

FILE: generator/test-constant-attribute-escaping/render_test.go
  function Test (line 14) | func Test(t *testing.T) {

FILE: generator/test-constant-attribute-escaping/template_templ.go
  function BasicTemplate (line 10) | func BasicTemplate() templ.Component {

FILE: generator/test-context/render_test.go
  function Test (line 16) | func Test(t *testing.T) {

FILE: generator/test-context/template_templ.go
  type contextKey (line 10) | type contextKey
  function render (line 14) | func render() templ.Component {

FILE: generator/test-css-expression/constants.go
  constant red (line 3) | red = "#ff0000"

FILE: generator/test-css-expression/render_test.go
  function TestCSSExpression (line 15) | func TestCSSExpression(t *testing.T) {

FILE: generator/test-css-expression/template_templ.go
  function className (line 10) | func className() templ.CSSClass {

FILE: generator/test-css-middleware/render_test.go
  function Test (line 22) | func Test(t *testing.T) {

FILE: generator/test-css-middleware/template_templ.go
  function red (line 10) | func red() templ.CSSClass {
  function render (line 20) | func render(s string) templ.Component {

FILE: generator/test-css-usage/render_test.go
  function Test (line 14) | func Test(t *testing.T) {

FILE: generator/test-css-usage/template_templ.go
  function StyleTagsAreSupported (line 15) | func StyleTagsAreSupported() templ.Component {
  constant red (line 46) | red = "#00ff00"
  function cssComponentGreen (line 48) | func cssComponentGreen() templ.CSSClass {
  function CSSComponentsAreSupported (line 58) | func CSSComponentsAreSupported() templ.Component {
  function CSSComponentsAndConstantsAreSupported (line 107) | func CSSComponentsAndConstantsAreSupported() templ.Component {
  function MapsCanBeUsedToConditionallySetClasses (line 177) | func MapsCanBeUsedToConditionallySetClasses() templ.Component {
  function d (line 225) | func d() templ.CSSClass {
  function e (line 235) | func e() templ.CSSClass {
  function KVCanBeUsedToConditionallySetClasses (line 245) | func KVCanBeUsedToConditionallySetClasses() templ.Component {
  function PseudoAttributesAndComplexClassNamesAreSupported (line 293) | func PseudoAttributesAndComplexClassNamesAreSupported() templ.Component {
  function ClassNamesAreHTMLEscaped (line 341) | func ClassNamesAreHTMLEscaped() templ.Component {
  function loading (line 389) | func loading(percent int) templ.CSSClass {
  function CSSComponentsCanBeUsedWithArguments (line 399) | func CSSComponentsCanBeUsedWithArguments() templ.Component {
  function windVaneRotation (line 468) | func windVaneRotation(degrees float64) templ.CSSClass {
  function Rotate (line 478) | func Rotate(degrees float64) templ.Component {
  function TestComponent (line 526) | func TestComponent() templ.Component {

FILE: generator/test-doctype-html4/render_test.go
  function Test (line 14) | func Test(t *testing.T) {

FILE: generator/test-doctype-html4/template_templ.go
  function Layout (line 10) | func Layout(title, content string) templ.Component {

FILE: generator/test-doctype/render_test.go
  function Test (line 14) | func Test(t *testing.T) {

FILE: generator/test-doctype/template_templ.go
  function Layout (line 10) | func Layout(title, content string) templ.Component {

FILE: generator/test-element-attributes/data.go
  type person (line 3) | type person struct

FILE: generator/test-element-attributes/render_test.go
  function Test (line 14) | func Test(t *testing.T) {

FILE: generator/test-element-attributes/template_templ.go
  function important (line 10) | func important() templ.CSSClass {
  function unimportant (line 20) | func unimportant() templ.CSSClass {
  function render (line 30) | func render(p person) templ.Component {

FILE: generator/test-elseif/data.go
  type data (line 3) | type data struct
    method IsTrue (line 6) | func (d data) IsTrue() bool {

FILE: generator/test-elseif/render_test.go
  function Test (line 14) | func Test(t *testing.T) {

FILE: generator/test-elseif/template_templ.go
  function render (line 10) | func render(d data) templ.Component {

FILE: generator/test-for/render_test.go
  function Test (line 14) | func Test(t *testing.T) {

FILE: generator/test-for/template_templ.go
  function render (line 10) | func render(items []string) templ.Component {

FILE: generator/test-form-action/render_test.go
  function Test (line 14) | func Test(t *testing.T) {

FILE: generator/test-form-action/template_templ.go
  function render (line 10) | func render() templ.Component {
  function safeUrl (line 91) | func safeUrl(s string) (templ.SafeURL, error) {
  function stringUrl (line 95) | func stringUrl(s string) (string, error) {

FILE: generator/test-fragment/render_test.go
  function Test (line 19) | func Test(t *testing.T) {

FILE: generator/test-fragment/template_templ.go
  function Page (line 10) | func Page() templ.Component {

FILE: generator/test-go-comments/render_test.go
  function Test (line 14) | func Test(t *testing.T) {

FILE: generator/test-go-comments/template_templ.go
  function render (line 10) | func render(content string) templ.Component {

FILE: generator/test-go-template-in-templ/render_test.go
  function TestExample (line 14) | func TestExample(t *testing.T) {

FILE: generator/test-go-template-in-templ/template_templ.go
  function Example (line 14) | func Example() templ.Component {

FILE: generator/test-html-comment/render_test.go
  function Test (line 14) | func Test(t *testing.T) {

FILE: generator/test-html-comment/template_templ.go
  function render (line 10) | func render(content string) templ.Component {
  function paragraph (line 76) | func paragraph(content string) templ.Component {

FILE: generator/test-html/data.go
  type person (line 3) | type person struct

FILE: generator/test-html/render_test.go
  function Test (line 14) | func Test(t *testing.T) {

FILE: generator/test-html/template_templ.go
  function render (line 10) | func render(p person) templ.Component {

FILE: generator/test-if/data.go
  type data (line 3) | type data struct
    method IsTrue (line 6) | func (d data) IsTrue() bool {

FILE: generator/test-if/render_test.go
  function Test (line 14) | func Test(t *testing.T) {

FILE: generator/test-if/template_templ.go
  function render (line 10) | func render(d data) templ.Component {

FILE: generator/test-ifelse/data.go
  type data (line 3) | type data struct
    method IsTrue (line 6) | func (d data) IsTrue() bool {

FILE: generator/test-ifelse/render_test.go
  function Test (line 14) | func Test(t *testing.T) {

FILE: generator/test-ifelse/template_templ.go
  function render (line 10) | func render(d data) templ.Component {

FILE: generator/test-import/render_test.go
  function Test (line 14) | func Test(t *testing.T) {

FILE: generator/test-import/template_templ.go
  function listItem (line 10) | func listItem() templ.Component {
  function list (line 47) | func list() templ.Component {
  function main (line 84) | func main() templ.Component {

FILE: generator/test-js-unsafe-usage/render_test.go
  function Test (line 14) | func Test(t *testing.T) {

FILE: generator/test-js-unsafe-usage/template_templ.go
  function TestComponent (line 10) | func TestComponent() templ.Component {

FILE: generator/test-js-usage/render_test.go
  function Test (line 14) | func Test(t *testing.T) {

FILE: generator/test-js-usage/template_templ.go
  function TestComponent (line 14) | func TestComponent() templ.Component {

FILE: generator/test-method/render_test.go
  function Test (line 14) | func Test(t *testing.T) {

FILE: generator/test-method/template_templ.go
  type Data (line 10) | type Data struct
    method Method (line 14) | func (d Data) Method() templ.Component {

FILE: generator/test-once/render_test.go
  function Test (line 14) | func Test(t *testing.T) {

FILE: generator/test-once/template_templ.go
  function hello (line 12) | func hello(label, name string) templ.Component {
  function render (line 89) | func render() templ.Component {

FILE: generator/test-only-scripts/render_test.go
  function Test (line 14) | func Test(t *testing.T) {

FILE: generator/test-only-scripts/template_templ.go
  function withParameters (line 10) | func withParameters(a string, b string, c int) templ.ComponentScript {

FILE: generator/test-primitives/render_test.go
  function Test (line 14) | func Test(t *testing.T) {

FILE: generator/test-primitives/template_templ.go
  function render (line 10) | func render() templ.Component {
  type stringish (line 273) | type stringish

FILE: generator/test-raw-elements/render_test.go
  function Test (line 14) | func Test(t *testing.T) {

FILE: generator/test-raw-elements/template_templ.go
  function Example (line 10) | func Example() templ.Component {

FILE: generator/test-script-expressions/render_test.go
  function Test (line 14) | func Test(t *testing.T) {

FILE: generator/test-script-expressions/template_templ.go
  function Script (line 10) | func Script[T any](name string, data T) templ.Component {
  function AllTests (line 112) | func AllTests() templ.Component {

FILE: generator/test-script-inline/render_test.go
  function Test (line 14) | func Test(t *testing.T) {

FILE: generator/test-script-inline/template_templ.go
  function withParameters (line 10) | func withParameters(a string, b string, c int) templ.ComponentScript {
  function withoutParameters (line 20) | func withoutParameters() templ.ComponentScript {
  function InlineJavascript (line 30) | func InlineJavascript(a string) templ.Component {

FILE: generator/test-script-usage-nonce/render_test.go
  function Test (line 15) | func Test(t *testing.T) {

FILE: generator/test-script-usage-nonce/template_templ.go
  function withParameters (line 10) | func withParameters(a string, b string, c int) templ.ComponentScript {
  function withoutParameters (line 20) | func withoutParameters() templ.ComponentScript {
  function onClick (line 30) | func onClick() templ.ComponentScript {
  function Button (line 40) | func Button(text string) templ.Component {
  function withComment (line 104) | func withComment() templ.ComponentScript {
  function ThreeButtons (line 114) | func ThreeButtons() templ.Component {
  function conditionalScript (line 172) | func conditionalScript() templ.ComponentScript {
  function Conditional (line 182) | func Conditional(show bool) templ.Component {

FILE: generator/test-script-usage/render_test.go
  function Test (line 14) | func Test(t *testing.T) {

FILE: generator/test-script-usage/template_templ.go
  function withParameters (line 10) | func withParameters(a string, b string, c int) templ.ComponentScript {
  function withoutParameters (line 20) | func withoutParameters() templ.ComponentScript {
  function onClick (line 30) | func onClick() templ.ComponentScript {
  function Button (line 40) | func Button(text string) templ.Component {
  function withComment (line 104) | func withComment() templ.ComponentScript {
  function whenButtonIsClicked (line 114) | func whenButtonIsClicked(event templ.JSExpression) templ.ComponentScript {
  function ThreeButtons (line 124) | func ThreeButtons() templ.Component {
  function conditionalScript (line 203) | func conditionalScript() templ.ComponentScript {
  function Conditional (line 213) | func Conditional(show bool) templ.Component {
  function alertTest (line 265) | func alertTest() templ.ComponentScript {
  function ScriptOnLoad (line 275) | func ScriptOnLoad() templ.Component {

FILE: generator/test-spread-attributes/render_test.go
  function Test (line 16) | func Test(t *testing.T) {
  function TestOrderedAttributes (line 67) | func TestOrderedAttributes(t *testing.T) {
  function nilPtr (line 115) | func nilPtr[T any]() *T {
  function ptr (line 119) | func ptr[T any](x T) *T {
  function TestNumericAttributeTypes (line 126) | func TestNumericAttributeTypes(t *testing.T) {

FILE: generator/test-spread-attributes/template_templ.go
  function BasicTemplate (line 10) | func BasicTemplate(spread templ.Attributes) templ.Component {
  function BasicTemplateOrdered (line 67) | func BasicTemplateOrdered(spread templ.OrderedAttributes) templ.Component {

FILE: generator/test-string-errors/render_test.go
  function Test (line 17) | func Test(t *testing.T) {

FILE: generator/test-string-errors/template_templ.go
  function funcWithNoError (line 10) | func funcWithNoError() (s string) {
  function funcWithError (line 14) | func funcWithError(in error) (s string, err error) {
  function TestComponent (line 21) | func TestComponent(err error) templ.Component {

FILE: generator/test-string/render_test.go
  function Test (line 14) | func Test(t *testing.T) {

FILE: generator/test-string/template_templ.go
  function render (line 10) | func render(s string) templ.Component {

FILE: generator/test-style-attribute/render_test.go
  function Test (line 16) | func Test(t *testing.T) {

FILE: generator/test-style-attribute/template_templ.go
  function Button (line 10) | func Button[T any](style T, text string) templ.Component {
  function getFunctionResult (line 91) | func getFunctionResult() (string, error) {

FILE: generator/test-switch/render_test.go
  constant expected (line 13) | expected = `it was &#39;a&#39;`
  function TestRender (line 15) | func TestRender(t *testing.T) {

FILE: generator/test-switch/template_templ.go
  function render (line 10) | func render(input string) templ.Component {

FILE: generator/test-switchdefault/render_test.go
  constant expected (line 13) | expected = `it was something else`
  function TestRender (line 15) | func TestRender(t *testing.T) {

FILE: generator/test-switchdefault/template_templ.go
  function template (line 10) | func template(input string) templ.Component {

FILE: generator/test-templ-element/render_test.go
  function Test (line 15) | func Test(t *testing.T) {

FILE: generator/test-templ-element/template_templ.go
  function wrapper (line 12) | func wrapper(index int) templ.Component {
  function template (line 62) | func template() templ.Component {

FILE: generator/test-templ-in-go-template/render_test.go
  function TestExample (line 17) | func TestExample(t *testing.T) {

FILE: generator/test-templ-in-go-template/template_templ.go
  function greeting (line 20) | func greeting() templ.Component {

FILE: generator/test-text-whitespace/render_test.go
  function TestTextWhitespace (line 12) | func TestTextWhitespace(t *testing.T) {

FILE: generator/test-text-whitespace/template_templ.go
  function WhitespaceIsAddedWithinTemplStatements (line 10) | func WhitespaceIsAddedWithinTemplStatements() templ.Component {
  constant WhitespaceIsAddedWithinTemplStatementsExpected (line 49) | WhitespaceIsAddedWithinTemplStatementsExpected = `<p>This is some text. ...
  function InlineElementsAreNotPadded (line 51) | func InlineElementsAreNotPadded() templ.Component {
  constant InlineElementsAreNotPaddedExpected (line 80) | InlineElementsAreNotPaddedExpected = `<p>Inline text <b>is spaced proper...
  function WhiteSpaceInHTMLIsNormalised (line 82) | func WhiteSpaceInHTMLIsNormalised() templ.Component {
  constant WhiteSpaceInHTMLIsNormalisedExpected (line 111) | WhiteSpaceInHTMLIsNormalisedExpected = `<p>newlines and other whitespace...
  function WhiteSpaceAroundValues (line 113) | func WhiteSpaceAroundValues() templ.Component {
  constant WhiteSpaceAroundValuesExpected (line 155) | WhiteSpaceAroundValuesExpected = `<p>templ allows strings to be included...
  constant WhiteSpaceAroundTemplatedValuesExpected (line 157) | WhiteSpaceAroundTemplatedValuesExpected = `<div>templ allows whitespace ...
  function WhiteSpaceAroundTemplatedValues (line 159) | func WhiteSpaceAroundTemplatedValues(prefix, statement string) templ.Com...

FILE: generator/test-text/render_test.go
  function Test (line 15) | func Test(t *testing.T) {

FILE: generator/test-text/template_templ.go
  function BasicTemplate (line 10) | func BasicTemplate(name string) templ.Component {

FILE: generator/test-void/render_test.go
  function Test (line 14) | func Test(t *testing.T) {

FILE: generator/test-void/template_templ.go
  function render (line 10) | func render() templ.Component {

FILE: generator/test-whitespace-around-go-keywords/render_test.go
  function TestTextWhitespace (line 12) | func TestTextWhitespace(t *testing.T) {

FILE: generator/test-whitespace-around-go-keywords/template_templ.go
  function WhitespaceIsConsistentInIf (line 12) | func WhitespaceIsConsistentInIf(firstIf, secondIf bool) templ.Component {
  constant WhitespaceIsConsistentInTrueIfExpected (line 61) | WhitespaceIsConsistentInTrueIfExpected = `<button>Start</button> <button...
  constant WhitespaceIsConsistentInTrueElseIfExpected (line 62) | WhitespaceIsConsistentInTrueElseIfExpected = `<button>Start</button> <bu...
  constant WhitespaceIsConsistentInTrueElseExpected (line 63) | WhitespaceIsConsistentInTrueElseExpected = `<button>Start</button> <butt...
  function WhitespaceIsConsistentInFalseIf (line 65) | func WhitespaceIsConsistentInFalseIf() templ.Component {
  constant WhitespaceIsConsistentInFalseIfExpected (line 104) | WhitespaceIsConsistentInFalseIfExpected = `<button>Start</button> <butto...
  function WhitespaceIsConsistentInSwitch (line 106) | func WhitespaceIsConsistentInSwitch(i int) templ.Component {
  constant WhitespaceIsConsistentInOneSwitchExpected (line 151) | WhitespaceIsConsistentInOneSwitchExpected = `<button>Start</button> <but...
  constant WhitespaceIsConsistentInDefaultSwitchExpected (line 152) | WhitespaceIsConsistentInDefaultSwitchExpected = `<button>Start</button> ...
  function WhitespaceIsConsistentInSwitchNoDefault (line 154) | func WhitespaceIsConsistentInSwitchNoDefault() templ.Component {
  constant WhitespaceIsConsistentInSwitchNoDefaultExpected (line 194) | WhitespaceIsConsistentInSwitchNoDefaultExpected = `<button>Start</button...
  function WhitespaceIsConsistentInFor (line 196) | func WhitespaceIsConsistentInFor(i int) templ.Component {
  constant WhitespaceIsConsistentInForZeroExpected (line 248) | WhitespaceIsConsistentInForZeroExpected = `<button>Start</button> <butto...
  constant WhitespaceIsConsistentInForOneExpected (line 249) | WhitespaceIsConsistentInForOneExpected = `<button>Start</button> <button...
  constant WhitespaceIsConsistentInForThreeExpected (line 250) | WhitespaceIsConsistentInForThreeExpected = `<button>Start</button> <butt...

FILE: handler.go
  type ComponentHandler (line 8) | type ComponentHandler struct
    method handleRenderErr (line 19) | func (ch *ComponentHandler) handleRenderErr(w http.ResponseWriter, r *...
    method ServeHTTPBufferedFragment (line 28) | func (ch *ComponentHandler) ServeHTTPBufferedFragment(w http.ResponseW...
    method ServeHTTPBufferedComplete (line 50) | func (ch *ComponentHandler) ServeHTTPBufferedComplete(w http.ResponseW...
    method ServeHTTPBuffered (line 72) | func (ch *ComponentHandler) ServeHTTPBuffered(w http.ResponseWriter, r...
    method ServeHTTPStreamed (line 83) | func (ch *ComponentHandler) ServeHTTPStreamed(w http.ResponseWriter, r...
    method ServeHTTP (line 109) | func (ch ComponentHandler) ServeHTTP(w http.ResponseWriter, r *http.Re...
  constant componentHandlerErrorMessage (line 17) | componentHandlerErrorMessage = "templ: failed to render template"
  function Handler (line 118) | func Handler(c Component, options ...func(*ComponentHandler)) *Component...
  function WithStatus (line 130) | func WithStatus(status int) func(*ComponentHandler) {
  function WithContentType (line 137) | func WithContentType(contentType string) func(*ComponentHandler) {
  function WithErrorHandler (line 144) | func WithErrorHandler(eh func(r *http.Request, err error) http.Handler) ...
  function WithStreaming (line 151) | func WithStreaming() func(*ComponentHandler) {
  function WithFragments (line 159) | func WithFragments(ids ...any) func(*ComponentHandler) {

FILE: handler_test.go
  function TestHandler (line 15) | func TestHandler(t *testing.T) {

FILE: internal/format/format_test.go
  function TestFormatting (line 13) | func TestFormatting(t *testing.T) {
  function showWhitespace (line 49) | func showWhitespace(s string) string {

FILE: internal/format/scriptelement.go
  constant templScriptPlaceholder (line 10) | templScriptPlaceholder = "templ_go_expression_7331"
  function ScriptElement (line 14) | func ScriptElement(se *parser.ScriptElement, depth int, prettierCommand ...

FILE: internal/format/styleelement.go
  function StyleElement (line 8) | func StyleElement(se *parser.RawElement, depth int, prettierCommand stri...

FILE: internal/format/templ.go
  type Config (line 13) | type Config struct
  function Templ (line 23) | func Templ(src []byte, fileName string, config Config) (output []byte, c...
  function applyPrettier (line 47) | func applyPrettier(t *parser.TemplateFile, config Config) (err error) {
  function calculateNodeDepth (line 91) | func calculateNodeDepth(e parser.Node, nodeToDepth map[parser.Node]int, ...

FILE: internal/htmlfind/htmlfind.go
  function AllReader (line 10) | func AllReader(r io.Reader, f Matcher) (nodes []*html.Node, err error) {
  function All (line 19) | func All(n *html.Node, f Matcher) (nodes []*html.Node) {
  type Matcher (line 30) | type Matcher
  type Attribute (line 33) | type Attribute struct
  function Attr (line 38) | func Attr(name, value string) Attribute {
  function Element (line 43) | func Element(name string, attrs ...Attribute) Matcher {
  function getAttributeValue (line 60) | func getAttributeValue(n *html.Node, name string) string {

FILE: internal/htmlfind/htmlfind_test.go
  function TestFind (line 12) | func TestFind(t *testing.T) {
  type errorReader (line 118) | type errorReader struct
    method Read (line 120) | func (errorReader) Read(p []byte) (n int, err error) {

FILE: internal/imports/process.go
  function convertTemplToGoURI (line 26) | func convertTemplToGoURI(templURI string) (isTemplFile bool, goURI strin...
  function isPackageUsedInAST (line 38) | func isPackageUsedInAST(file *ast.File, pkgName string) (isPackageUsed b...
  function updateImports (line 56) | func updateImports(name, src string) (updated []*ast.ImportSpec, parsedF...
  function Process (line 75) | func Process(t *parser.TemplateFile) (*parser.TemplateFile, error) {
  function getImportDetails (line 182) | func getImportDetails(imp *ast.ImportSpec) (name, importPath string, err...
  function getPackageIdentifier (line 196) | func getPackageIdentifier(name, importPath string) string {
  function containsImport (line 211) | func containsImport(imports []*ast.ImportSpec, spec *ast.ImportSpec) bool {

FILE: internal/imports/process_test.go
  function TestFormatting (line 17) | func TestFormatting(t *testing.T) {
  function showWhitespace (line 54) | func showWhitespace(s string) string {
  function clean (line 61) | func clean(b []byte) string {
  function TestImport (line 67) | func TestImport(t *testing.T) {

FILE: internal/lazyloader/docheader.go
  type docHeader (line 7) | type docHeader interface
  type goDocHeader (line 11) | type goDocHeader struct
    method equal (line 16) | func (h *goDocHeader) equal(other docHeader) bool {

FILE: internal/lazyloader/docheader_test.go
  function TestGoDocHeaderEqual (line 9) | func TestGoDocHeaderEqual(t *testing.T) {
  type mockDocHeader (line 93) | type mockDocHeader struct
    method equal (line 95) | func (m mockDocHeader) equal(_ docHeader) bool {

FILE: internal/lazyloader/docheaderparser.go
  type docHeaderParser (line 11) | type docHeaderParser interface
  type goDocHeaderParser (line 15) | type goDocHeaderParser struct
    method parse (line 30) | func (p *goDocHeaderParser) parse(filename string) docHeader {
  type fileParser (line 20) | type fileParser interface
  type goFileParser (line 24) | type goFileParser struct
    method parseFile (line 26) | func (goFileParser) parseFile(fset *token.FileSet, file string, overla...

FILE: internal/lazyloader/docheaderparser_test.go
  function TestGoDocHeaderParserParse (line 12) | func TestGoDocHeaderParserParse(t *testing.T) {
  type mockFileParser (line 101) | type mockFileParser struct
    method parseFile (line 106) | func (m mockFileParser) parseFile(fset *token.FileSet, file string, _ ...

FILE: internal/lazyloader/pkgloader.go
  type pkgLoader (line 16) | type pkgLoader interface
  type goPkgLoader (line 20) | type goPkgLoader struct
    method load (line 25) | func (l *goPkgLoader) load(file string) (*packages.Package, error) {
    method prepareOverlay (line 49) | func (l *goPkgLoader) prepareOverlay() map[string][]byte {

FILE: internal/lazyloader/pkgloader_test.go
  function TestGoPkgLoaderLoad (line 11) | func TestGoPkgLoaderLoad(t *testing.T) {

FILE: internal/lazyloader/pkgtraverser.go
  constant _templExt (line 15) | _templExt = ".templ"
  type pkgTraverser (line 18) | type pkgTraverser interface
  type goPkgTraverser (line 23) | type goPkgTraverser struct
    method openTopologically (line 44) | func (t *goPkgTraverser) openTopologically(ctx context.Context, pkg *p...
    method closeTopologically (line 82) | func (t *goPkgTraverser) closeTopologically(ctx context.Context, pkg *...
  type TemplDocHandler (line 29) | type TemplDocHandler interface
  type fileReader (line 34) | type fileReader interface
  type templFileReader (line 38) | type templFileReader struct
    method read (line 40) | func (templFileReader) read(file string) ([]byte, error) {

FILE: internal/lazyloader/pkgtraverser_test.go
  function TestTemplPkgTraverserOpenTopologically (line 13) | func TestTemplPkgTraverserOpenTopologically(t *testing.T) {
  function TestTemplPkgTraverserCloseTopologically (line 355) | func TestTemplPkgTraverserCloseTopologically(t *testing.T) {
  type mockFileReader (line 681) | type mockFileReader struct
    method read (line 686) | func (r mockFileReader) read(_ string) ([]byte, error) {
  type mockTemplDocHandler (line 690) | type mockTemplDocHandler struct
    method HandleDidOpen (line 696) | func (h *mockTemplDocHandler) HandleDidOpen(_ context.Context, params ...
    method HandleDidClose (line 701) | func (h *mockTemplDocHandler) HandleDidClose(_ context.Context, params...

FILE: internal/lazyloader/templdoclazyloader.go
  type TemplDocLazyLoader (line 13) | type TemplDocLazyLoader interface
  type templDocLazyLoader (line 28) | type templDocLazyLoader struct
    method Load (line 68) | func (l *templDocLazyLoader) Load(ctx context.Context, params *lsp.Did...
    method Sync (line 91) | func (l *templDocLazyLoader) Sync(ctx context.Context, params *lsp.Did...
    method Unload (line 132) | func (l *templDocLazyLoader) Unload(ctx context.Context, params *lsp.D...
    method HasLoaded (line 154) | func (l *templDocLazyLoader) HasLoaded(doc lsp.TextDocumentIdentifier)...
  type NewParams (line 39) | type NewParams struct
  function New (line 45) | func New(params NewParams) TemplDocLazyLoader {

FILE: internal/lazyloader/templdoclazyloader_test.go
  function TestTemplDocLazyLoaderLoad (line 14) | func TestTemplDocLazyLoaderLoad(t *testing.T) {
  function TestTemplDocLazyLoaderSync (line 131) | func TestTemplDocLazyLoaderSync(t *testing.T) {
  function TestTemplDocLazyLoaderUnload (line 568) | func TestTemplDocLazyLoaderUnload(t *testing.T) {
  function TestTemplDocLazyLoaderHasLoaded (line 686) | func TestTemplDocLazyLoaderHasLoaded(t *testing.T) {
  type mockPkgTraverser (line 735) | type mockPkgTraverser struct
    method openTopologically (line 742) | func (t *mockPkgTraverser) openTopologically(_ context.Context, pkg *p...
    method closeTopologically (line 750) | func (t *mockPkgTraverser) closeTopologically(_ context.Context, pkg *...
  type mockDocHeaderParser (line 758) | type mockDocHeaderParser struct
    method parse (line 762) | func (p *mockDocHeaderParser) parse(filename string) docHeader {

FILE: internal/prettier/prettier.go
  constant defaultPosixCommand (line 15) | defaultPosixCommand = "prettier --use-tabs --stdin-filepath $TEMPL_PRETT...
  function DefaultCommand (line 22) | func DefaultCommand() string {
  function IsAvailable (line 34) | func IsAvailable(command string) bool {
  function Run (line 51) | func Run(input, fileName, command string) (formatted string, err error) {
  function getCommand (line 62) | func getCommand(goos, shell, command string) *exec.Cmd {
  function Element (line 72) | func Element(name string, typeAttrValue string, content string, depth in...

FILE: internal/prettier/prettier_test.go
  function Test (line 10) | func Test(t *testing.T) {
  function TestIsAvailable (line 35) | func TestIsAvailable(t *testing.T) {
  function TestGetCommand (line 52) | func TestGetCommand(t *testing.T) {

FILE: internal/skipdir/skipdir.go
  function ShouldSkip (line 8) | func ShouldSkip(path string) (skip bool) {

FILE: internal/skipdir/skipdir_test.go
  function TestSkipDir (line 5) | func TestSkipDir(t *testing.T) {

FILE: internal/syncmap/map.go
  function New (line 5) | func New[K comparable, V any]() *Map[K, V] {
  type Map (line 12) | type Map struct
  method Get (line 17) | func (m *Map[K, V]) Get(key K) (v V, ok bool) {
  method Set (line 24) | func (m *Map[K, V]) Set(key K, value V) {
  method Delete (line 30) | func (m *Map[K, V]) Delete(key K) {
  method CompareAndSwap (line 36) | func (m *Map[K, V]) CompareAndSwap(key K, shouldUpdate func(previous, up...
  function UpdateIfChanged (line 47) | func UpdateIfChanged[V comparable](previous, updated V) bool {

FILE: internal/syncmap/map_test.go
  function TestMap (line 5) | func TestMap(t *testing.T) {

FILE: internal/syncset/set.go
  function New (line 5) | func New[T comparable]() *Set[T] {
  type Set (line 12) | type Set struct
  method Get (line 17) | func (s *Set[T]) Get(key T) (ok bool) {
  method Set (line 24) | func (s *Set[T]) Set(key T) {
  method Delete (line 30) | func (s *Set[T]) Delete(key T) (deleted bool) {
  method Count (line 38) | func (s *Set[T]) Count() int {

FILE: internal/syncset/set_test.go
  function TestSet (line 5) | func TestSet(t *testing.T) {

FILE: join.go
  function Join (line 10) | func Join(components ...Component) Component {

FILE: join_test.go
  function TestJoin (line 14) | func TestJoin(t *testing.T) {

FILE: js.go
  function JSUnsafeFuncCall (line 13) | func JSUnsafeFuncCall[T ~string](js T) ComponentScript {
  function JSFuncCall (line 29) | func JSFuncCall[T ~string](functionName T, args ...any) ComponentScript {

FILE: js_test.go
  function TestJSUnsafeFuncCall (line 13) | func TestJSUnsafeFuncCall(t *testing.T) {
  function TestJSFuncCall (line 53) | func TestJSFuncCall(t *testing.T) {
  function TestJSFunctionNameRegexp (line 146) | func TestJSFunctionNameRegexp(t *testing.T) {

FILE: jsonscript.go
  function JSONScript (line 14) | func JSONScript(id string, data any) JSONScriptElement {
  type JSONScriptElement (line 43) | type JSONScriptElement struct
    method WithType (line 24) | func (j JSONScriptElement) WithType(t string) JSONScriptElement {
    method WithNonceFromString (line 30) | func (j JSONScriptElement) WithNonceFromString(nonce string) JSONScrip...
    method WithNonceFrom (line 38) | func (j JSONScriptElement) WithNonceFrom(f func(context.Context) strin...
    method Render (line 56) | func (j JSONScriptElement) Render(ctx context.Context, w io.Writer) (e...

FILE: jsonscript_test.go
  function TestJSONScriptElement (line 12) | func TestJSONScriptElement(t *testing.T) {

FILE: jsonstring.go
  function JSONString (line 8) | func JSONString(v any) (string, error) {

FILE: jsonstring_test.go
  function TestJSONString (line 9) | func TestJSONString(t *testing.T) {

FILE: lsp/jsonrpc2/codes.go
  type Code (line 7) | type Code
  constant ParseError (line 13) | ParseError Code = -32700
  constant InvalidRequest (line 16) | InvalidRequest Code = -32600
  constant MethodNotFound (line 19) | MethodNotFound Code = -32601
  constant InvalidParams (line 22) | InvalidParams Code = -32602
  constant InternalError (line 25) | InternalError Code = -32603
  constant JSONRPCReservedErrorRangeStart (line 35) | JSONRPCReservedErrorRangeStart Code = -32099
  constant CodeServerErrorStart (line 40) | CodeServerErrorStart = JSONRPCReservedErrorRangeStart
  constant ServerNotInitialized (line 43) | ServerNotInitialized Code = -32002
  constant UnknownError (line 46) | UnknownError Code = -32001
  constant JSONRPCReservedErrorRangeEnd (line 53) | JSONRPCReservedErrorRangeEnd Code = -32000
  constant CodeServerErrorEnd (line 58) | CodeServerErrorEnd = JSONRPCReservedErrorRangeEnd

FILE: lsp/jsonrpc2/conn.go
  type Conn (line 20) | type Conn interface
  type conn (line 64) | type conn struct
    method Call (line 86) | func (c *conn) Call(ctx context.Context, method string, params, result...
    method Notify (line 142) | func (c *conn) Notify(ctx context.Context, method string, params any) ...
    method replier (line 153) | func (c *conn) replier(req Message) Replier {
    method write (line 175) | func (c *conn) write(ctx context.Context, msg Message) (int64, error) {
    method Go (line 187) | func (c *conn) Go(ctx context.Context, handler Handler) {
    method run (line 191) | func (c *conn) run(ctx context.Context, handler Handler) {
    method Close (line 223) | func (c *conn) Close() error {
    method Done (line 228) | func (c *conn) Done() <-chan struct{} {
    method Err (line 233) | func (c *conn) Err() error {
    method fail (line 241) | func (c *conn) fail(err error) {
  function NewConn (line 76) | func NewConn(s Stream) Conn {

FILE: lsp/jsonrpc2/errors.go
  type Error (line 14) | type Error struct
    method Error (line 30) | func (e *Error) Error() string {
    method Unwrap (line 40) | func (e *Error) Unwrap() error { return errors.New(e.Message) }
  function NewError (line 43) | func NewError(c Code, message string) *Error {
  function Errorf (line 51) | func Errorf(c Code, format string, args ...any) *Error {
  type constErr (line 59) | type constErr
    method Error (line 65) | func (e constErr) Error() string { return string(e) }
  constant ErrIdleTimeout (line 69) | ErrIdleTimeout = constErr("timed out waiting for new connections")

FILE: lsp/jsonrpc2/handler.go
  type Handler (line 15) | type Handler
  type Replier (line 20) | type Replier
  function MethodNotFoundHandler (line 26) | func MethodNotFoundHandler(ctx context.Context, reply Replier, req Reque...
  function ReplyHandler (line 32) | func ReplyHandler(handler Handler) (h Handler) {
  function CancelHandler (line 54) | func CancelHandler(handler Handler) (h Handler, canceller func(id ID)) {
  function AsyncHandler (line 98) | func AsyncHandler(handler Handler) (h Handler) {

FILE: lsp/jsonrpc2/jsonrpc2_test.go
  constant methodNoArgs (line 22) | methodNoArgs    = "no_args"
  constant methodOneString (line 23) | methodOneString = "one_string"
  constant methodOneNumber (line 24) | methodOneNumber = "one_number"
  constant methodJoin (line 25) | methodJoin      = "join"
  type callTest (line 28) | type callTest struct
    method newResults (line 58) | func (test *callTest) newResults() any {
    method verifyResults (line 75) | func (test *callTest) verifyResults(t *testing.T, results any) {
  function TestRequest (line 88) | func TestRequest(t *testing.T) {
  function prepare (line 109) | func prepare(ctx context.Context, t *testing.T) (a, b jsonrpc2.Conn, don...
  function run (line 126) | func run(ctx context.Context, nc io.ReadWriteCloser) jsonrpc2.Conn {
  function testHandler (line 134) | func testHandler() jsonrpc2.Handler {

FILE: lsp/jsonrpc2/message.go
  type Message (line 20) | type Message interface
  type Request (line 30) | type Request interface
  type Call (line 45) | type Call struct
    method ID (line 74) | func (c *Call) ID() ID { return c.id }
    method Method (line 77) | func (c *Call) Method() string { return c.method }
    method Params (line 80) | func (c *Call) Params() json.RawMessage { return c.params }
    method jsonrpc2Message (line 83) | func (Call) jsonrpc2Message() {}
    method jsonrpc2Request (line 86) | func (Call) jsonrpc2Request() {}
    method MarshalJSON (line 89) | func (c Call) MarshalJSON() ([]byte, error) {
    method UnmarshalJSON (line 104) | func (c *Call) UnmarshalJSON(data []byte) error {
  function NewCall (line 63) | func NewCall(id ID, method string, params any) (*Call, error) {
  type Response (line 125) | type Response struct
    method ID (line 154) | func (r *Response) ID() ID { return r.id }
    method Result (line 157) | func (r *Response) Result() json.RawMessage { return r.result }
    method Err (line 160) | func (r *Response) Err() error { return r.err }
    method jsonrpc2Message (line 163) | func (r *Response) jsonrpc2Message() {}
    method MarshalJSON (line 166) | func (r Response) MarshalJSON() ([]byte, error) {
    method UnmarshalJSON (line 184) | func (r *Response) UnmarshalJSON(data []byte) error {
  function NewResponse (line 143) | func NewResponse(id ID, result any, err error) (*Response, error) {
  function toError (line 204) | func toError(err error) *Error {
  type Notification (line 228) | type Notification struct
    method Method (line 254) | func (n *Notification) Method() string { return n.method }
    method Params (line 257) | func (n *Notification) Params() json.RawMessage { return n.params }
    method jsonrpc2Message (line 260) | func (Notification) jsonrpc2Message() {}
    method jsonrpc2Request (line 263) | func (Notification) jsonrpc2Request() {}
    method MarshalJSON (line 266) | func (n Notification) MarshalJSON() ([]byte, error) {
    method UnmarshalJSON (line 280) | func (n *Notification) UnmarshalJSON(data []byte) error {
  function NewNotification (line 244) | func NewNotification(method string, params any) (*Notification, error) {
  function DecodeMessage (line 296) | func DecodeMessage(data []byte) (Message, error) {
  function marshalInterface (line 348) | func marshalInterface(obj any) (json.RawMessage, error) {

FILE: lsp/jsonrpc2/serve.go
  type StreamServer (line 21) | type StreamServer interface
  type ServerFunc (line 27) | type ServerFunc
    method ServeStream (line 32) | func (f ServerFunc) ServeStream(ctx context.Context, c Conn) error {
  function HandlerServer (line 38) | func HandlerServer(h Handler) StreamServer {
  function ListenAndServe (line 50) | func ListenAndServe(ctx context.Context, network, addr string, server St...
  function Serve (line 69) | func Serve(ctx context.Context, ln net.Listener, server StreamServer, id...

FILE: lsp/jsonrpc2/serve_test.go
  function TestIdleTimeout (line 17) | func TestIdleTimeout(t *testing.T) {

FILE: lsp/jsonrpc2/stream.go
  constant HdrContentLength (line 23) | HdrContentLength = "Content-Length"
  constant HdrContentType (line 30) | HdrContentType = "Content-Type"
  constant HdrContentSeparator (line 33) | HdrContentSeparator = "\r\n\r\n"
  type Framer (line 40) | type Framer
  type Stream (line 50) | type Stream interface
  type rawStream (line 62) | type rawStream struct
    method Read (line 79) | func (s *rawStream) Read(ctx context.Context) (Message, int64, error) {
    method Write (line 96) | func (s *rawStream) Write(ctx context.Context, msg Message) (int64, er...
    method Close (line 117) | func (s *rawStream) Close() error {
  function NewRawStream (line 71) | func NewRawStream(conn io.ReadWriteCloser) Stream {
  type stream (line 121) | type stream struct
    method Read (line 138) | func (s *stream) Read(ctx context.Context) (Message, int64, error) {
    method Write (line 195) | func (s *stream) Write(ctx context.Context, msg Message) (int64, error) {
    method Close (line 223) | func (s *stream) Close() error {
  function NewStream (line 130) | func NewStream(conn io.ReadWriteCloser) Stream {

FILE: lsp/jsonrpc2/wire.go
  constant Version (line 13) | Version = "2.0"
  type version (line 18) | type version struct
    method MarshalJSON (line 27) | func (version) MarshalJSON() ([]byte, error) {
    method UnmarshalJSON (line 32) | func (version) UnmarshalJSON(data []byte) error {
  type ID (line 47) | type ID struct
    method Format (line 69) | func (id ID) Format(f fmt.State, r rune) {
    method MarshalJSON (line 84) | func (id *ID) MarshalJSON() ([]byte, error) {
    method UnmarshalJSON (line 92) | func (id *ID) UnmarshalJSON(data []byte) error {
  function NewNumberID (line 60) | func NewNumberID(v int32) ID { return ID{number: v} }
  function NewStringID (line 63) | func NewStringID(v string) ID { return ID{name: v} }
  type wireRequest (line 101) | type wireRequest struct
  type wireResponse (line 119) | type wireResponse struct
  type combined (line 133) | type combined struct

FILE: lsp/jsonrpc2/wire_test.go
  function TestIDFormat (line 44) | func TestIDFormat(t *testing.T) {
  function TestIDEncode (line 62) | func TestIDEncode(t *testing.T) {
  function TestIDDecode (line 79) | func TestIDDecode(t *testing.T) {
  function TestErrorEncode (line 104) | func TestErrorEncode(t *testing.T) {
  function TestErrorResponse (line 118) | func TestErrorResponse(t *testing.T) {
  function checkJSON (line 139) | func checkJSON(t *testing.T, got, want []byte) {

FILE: lsp/protocol/base.go
  type CancelParams (line 12) | type CancelParams struct
  type ProgressParams (line 20) | type ProgressParams struct
  type ProgressToken (line 31) | type ProgressToken struct
    method Format (line 58) | func (v ProgressToken) Format(f fmt.State, r rune) {
    method String (line 74) | func (v ProgressToken) String() string {
    method MarshalJSON (line 79) | func (v *ProgressToken) MarshalJSON() ([]byte, error) {
    method UnmarshalJSON (line 88) | func (v *ProgressToken) UnmarshalJSON(data []byte) error {
  function NewProgressToken (line 45) | func NewProgressToken(s string) *ProgressToken {
  function NewNumberProgressToken (line 50) | func NewNumberProgressToken(n int32) *ProgressToken {

FILE: lsp/protocol/base_test.go
  function TestCancelParams (line 16) | func TestCancelParams(t *testing.T) {
  function TestProgressParams (line 97) | func TestProgressParams(t *testing.T) {

FILE: lsp/protocol/basic.go
  type Position (line 38) | type Position struct
  type Range (line 61) | type Range struct
  type Location (line 70) | type Location struct
  type LocationLink (line 76) | type LocationLink struct
  type Command (line 108) | type Command struct
  type TextEdit (line 120) | type TextEdit struct
  type ChangeAnnotation (line 134) | type ChangeAnnotation struct
  type ChangeAnnotationIdentifier (line 152) | type ChangeAnnotationIdentifier
  type AnnotatedTextEdit (line 157) | type AnnotatedTextEdit struct
  type TextDocumentEdit (line 173) | type TextDocumentEdit struct
  type ResourceOperationKind (line 185) | type ResourceOperationKind
  constant CreateResourceOperation (line 189) | CreateResourceOperation ResourceOperationKind = "create"
  constant RenameResourceOperation (line 192) | RenameResourceOperation ResourceOperationKind = "rename"
  constant DeleteResourceOperation (line 195) | DeleteResourceOperation ResourceOperationKind = "delete"
  type CreateFileOptions (line 199) | type CreateFileOptions struct
  type CreateFile (line 208) | type CreateFile struct
  type RenameFileOptions (line 225) | type RenameFileOptions struct
  type RenameFile (line 234) | type RenameFile struct
  type DeleteFileOptions (line 254) | type DeleteFileOptions struct
  type DeleteFile (line 263) | type DeleteFile struct
  type WorkspaceEdit (line 284) | type WorkspaceEdit struct
  type TextDocumentIdentifier (line 312) | type TextDocumentIdentifier struct
  type TextDocumentItem (line 318) | type TextDocumentItem struct
  type LanguageIdentifier (line 334) | type LanguageIdentifier
  constant ABAPLanguage (line 338) | ABAPLanguage LanguageIdentifier = "abap"
  constant BatLanguage (line 341) | BatLanguage LanguageIdentifier = "bat"
  constant BibtexLanguage (line 344) | BibtexLanguage LanguageIdentifier = "bibtex"
  constant ClojureLanguage (line 347) | ClojureLanguage LanguageIdentifier = "clojure"
  constant CoffeeScriptLanguage (line 350) | CoffeeScriptLanguage LanguageIdentifier = "coffeescript"
  constant CLanguage (line 353) | CLanguage LanguageIdentifier = "c"
  constant CppLanguage (line 356) | CppLanguage LanguageIdentifier = "cpp"
  constant CsharpLanguage (line 359) | CsharpLanguage LanguageIdentifier = "csharp"
  constant CSSLanguage (line 362) | CSSLanguage LanguageIdentifier = "css"
  constant DiffLanguage (line 365) | DiffLanguage LanguageIdentifier = "diff"
  constant DartLanguage (line 368) | DartLanguage LanguageIdentifier = "dart"
  constant DockerfileLanguage (line 371) | DockerfileLanguage LanguageIdentifier = "dockerfile"
  constant ElixirLanguage (line 374) | ElixirLanguage LanguageIdentifier = "elixir"
  constant ErlangLanguage (line 377) | ErlangLanguage LanguageIdentifier = "erlang"
  constant FsharpLanguage (line 380) | FsharpLanguage LanguageIdentifier = "fsharp"
  constant GitCommitLanguage (line 383) | GitCommitLanguage LanguageIdentifier = "git-commit"
  constant GitRebaseLanguage (line 386) | GitRebaseLanguage LanguageIdentifier = "git-rebase"
  constant GoLanguage (line 389) | GoLanguage LanguageIdentifier = "go"
  constant GroovyLanguage (line 392) | GroovyLanguage LanguageIdentifier = "groovy"
  constant HandlebarsLanguage (line 395) | HandlebarsLanguage LanguageIdentifier = "handlebars"
  constant HTMLLanguage (line 398) | HTMLLanguage LanguageIdentifier = "html"
  constant IniLanguage (line 401) | IniLanguage LanguageIdentifier = "ini"
  constant JavaLanguage (line 404) | JavaLanguage LanguageIdentifier = "java"
  constant JavaScriptLanguage (line 407) | JavaScriptLanguage LanguageIdentifier = "javascript"
  constant JavaScriptReactLanguage (line 410) | JavaScriptReactLanguage LanguageIdentifier = "javascriptreact"
  constant JSONLanguage (line 413) | JSONLanguage LanguageIdentifier = "json"
  constant LatexLanguage (line 416) | LatexLanguage LanguageIdentifier = "latex"
  constant LessLanguage (line 419) | LessLanguage LanguageIdentifier = "less"
  constant LuaLanguage (line 422) | LuaLanguage LanguageIdentifier = "lua"
  constant MakefileLanguage (line 425) | MakefileLanguage LanguageIdentifier = "makefile"
  constant MarkdownLanguage (line 428) | MarkdownLanguage LanguageIdentifier = "markdown"
  constant ObjectiveCLanguage (line 431) | ObjectiveCLanguage LanguageIdentifier = "objective-c"
  constant ObjectiveCppLanguage (line 434) | ObjectiveCppLanguage LanguageIdentifier = "objective-cpp"
  constant PerlLanguage (line 437) | PerlLanguage LanguageIdentifier = "perl"
  constant Perl6Language (line 440) | Perl6Language LanguageIdentifier = "perl6"
  constant PHPLanguage (line 443) | PHPLanguage LanguageIdentifier = "php"
  constant PowershellLanguage (line 446) | PowershellLanguage LanguageIdentifier = "powershell"
  constant JadeLanguage (line 449) | JadeLanguage LanguageIdentifier = "jade"
  constant PythonLanguage (line 452) | PythonLanguage LanguageIdentifier = "python"
  constant RLanguage (line 455) | RLanguage LanguageIdentifier = "r"
  constant RazorLanguage (line 458) | RazorLanguage LanguageIdentifier = "razor"
  constant RubyLanguage (line 461) | RubyLanguage LanguageIdentifier = "ruby"
  constant RustLanguage (line 464) | RustLanguage LanguageIdentifier = "rust"
  constant SCSSLanguage (line 467) | SCSSLanguage LanguageIdentifier = "scss"
  constant SASSLanguage (line 470) | SASSLanguage LanguageIdentifier = "sass"
  constant ScalaLanguage (line 473) | ScalaLanguage LanguageIdentifier = "scala"
  constant ShaderlabLanguage (line 476) | ShaderlabLanguage LanguageIdentifier = "shaderlab"
  constant ShellscriptLanguage (line 479) | ShellscriptLanguage LanguageIdentifier = "shellscript"
  constant SQLLanguage (line 482) | SQLLanguage LanguageIdentifier = "sql"
  constant SwiftLanguage (line 485) | SwiftLanguage LanguageIdentifier = "swift"
  constant TypeScriptLanguage (line 488) | TypeScriptLanguage LanguageIdentifier = "typescript"
  constant TypeScriptReactLanguage (line 491) | TypeScriptReactLanguage LanguageIdentifier = "typescriptreact"
  constant TeXLanguage (line 494) | TeXLanguage LanguageIdentifier = "tex"
  constant VBLanguage (line 497) | VBLanguage LanguageIdentifier = "vb"
  constant XMLLanguage (line 500) | XMLLanguage LanguageIdentifier = "xml"
  constant XslLanguage (line 503) | XslLanguage LanguageIdentifier = "xsl"
  constant YamlLanguage (line 506) | YamlLanguage LanguageIdentifier = "yaml"
  function ToLanguageIdentifier (line 571) | func ToLanguageIdentifier(ft string) LanguageIdentifier {
  type VersionedTextDocumentIdentifier (line 583) | type VersionedTextDocumentIdentifier struct
  type OptionalVersionedTextDocumentIdentifier (line 599) | type OptionalVersionedTextDocumentIdentifier struct
  type TextDocumentPositionParams (line 622) | type TextDocumentPositionParams struct
  type DocumentFilter (line 633) | type DocumentFilter struct
  type DocumentSelector (line 659) | type DocumentSelector
  type MarkupKind (line 666) | type MarkupKind
  constant PlainText (line 670) | PlainText MarkupKind = "plaintext"
  constant Markdown (line 673) | Markdown MarkupKind = "markdown"
  type MarkupContent (line 699) | type MarkupContent struct

FILE: lsp/protocol/basic_test.go
  function TestPosition (line 15) | func TestPosition(t *testing.T) {
  function TestRange (line 108) | func TestRange(t *testing.T) {
  function TestLocation (line 207) | func TestLocation(t *testing.T) {
  function TestLocationLink (line 309) | func TestLocationLink(t *testing.T) {
  function TestCodeDescription (line 471) | func TestCodeDescription(t *testing.T) {
  function TestCommand (line 567) | func TestCommand(t *testing.T) {
  function TestChangeAnnotation (line 684) | func TestChangeAnnotation(t *testing.T) {
  function TestAnnotatedTextEdit (line 800) | func TestAnnotatedTextEdit(t *testing.T) {
  function TestTextEdit (line 911) | func TestTextEdit(t *testing.T) {
  function TestTextDocumentEdit (line 1044) | func TestTextDocumentEdit(t *testing.T) {
  function TestCreateFileOptions (line 1185) | func TestCreateFileOptions(t *testing.T) {
  function TestCreateFile (line 1345) | func TestCreateFile(t *testing.T) {
  function TestRenameFileOptions (line 1468) | func TestRenameFileOptions(t *testing.T) {
  function TestRenameFile (line 1628) | func TestRenameFile(t *testing.T) {
  function TestDeleteFileOptions (line 1753) | func TestDeleteFileOptions(t *testing.T) {
  function TestDeleteFile (line 1903) | func TestDeleteFile(t *testing.T) {
  function TestWorkspaceEdit (line 2026) | func TestWorkspaceEdit(t *testing.T) {
  function TestTextDocumentIdentifier (line 2248) | func TestTextDocumentIdentifier(t *testing.T) {
  function TestTextDocumentItem (line 2354) | func TestTextDocumentItem(t *testing.T) {
  function TestToLanguageIdentifier (line 2455) | func TestToLanguageIdentifier(t *testing.T) {
  function TestVersionedTextDocumentIdentifier (line 2491) | func TestVersionedTextDocumentIdentifier(t *testing.T) {
  function TestOptionalVersionedTextDocumentIdentifier (line 2612) | func TestOptionalVersionedTextDocumentIdentifier(t *testing.T) {
  function TestTextDocumentPositionParams (line 2733) | func TestTextDocumentPositionParams(t *testing.T) {
  function TestDocumentFilter (line 2837) | func TestDocumentFilter(t *testing.T) {
  function TestDocumentSelector (line 3009) | func TestDocumentSelector(t *testing.T) {
  function TestMarkupContent (line 3116) | func TestMarkupContent(t *testing.T) {

FILE: lsp/protocol/callhierarchy.go
  type CallHierarchy (line 9) | type CallHierarchy struct
  type CallHierarchyPrepareParams (line 21) | type CallHierarchyPrepareParams struct
  type CallHierarchyItem (line 29) | type CallHierarchyItem struct
  type CallHierarchyIncomingCallsParams (line 62) | type CallHierarchyIncomingCallsParams struct
  type CallHierarchyIncomingCall (line 73) | type CallHierarchyIncomingCall struct
  type CallHierarchyOutgoingCallsParams (line 85) | type CallHierarchyOutgoingCallsParams struct
  type CallHierarchyOutgoingCall (line 96) | type CallHierarchyOutgoingCall struct

FILE: lsp/protocol/callhierarchy_test.go
  function TestCallHierarchy (line 17) | func TestCallHierarchy(t *testing.T) {
  function TestCallHierarchyOptions (line 129) | func TestCallHierarchyOptions(t *testing.T) {
  function TestCallHierarchyRegistrationOptions (line 243) | func TestCallHierarchyRegistrationOptions(t *testing.T) {
  function TestCallHierarchyPrepareParams (line 375) | func TestCallHierarchyPrepareParams(t *testing.T) {
  function TestCallHierarchyItem (line 518) | func TestCallHierarchyItem(t *testing.T) {
  function TestCallHierarchyIncomingCallsParams (line 681) | func TestCallHierarchyIncomingCallsParams(t *testing.T) {
  function TestCallHierarchyIncomingCall (line 870) | func TestCallHierarchyIncomingCall(t *testing.T) {
  function TestCallHierarchyOutgoingCallsParams (line 1007) | func TestCallHierarchyOutgoingCallsParams(t *testing.T) {
  function TestCallHierarchyOutgoingCall (line 1196) | func TestCallHierarchyOutgoingCall(t *testing.T) {

FILE: lsp/protocol/capabilities_client.go
  type ClientCapabilities (line 19) | type ClientCapabilities struct
  type WorkspaceClientCapabilities (line 39) | type WorkspaceClientCapabilities struct
  type WorkspaceClientCapabilitiesWorkspaceEdit (line 88) | type WorkspaceClientCapabilitiesWorkspaceEdit struct
  type FailureHandlingKind (line 118) | type FailureHandlingKind
  constant FailureHandlingKindAbort (line 123) | FailureHandlingKindAbort FailureHandlingKind = "abort"
  constant FailureHandlingKindTransactional (line 127) | FailureHandlingKindTransactional FailureHandlingKind = "transactional"
  constant FailureHandlingKindTextOnlyTransactional (line 132) | FailureHandlingKindTextOnlyTransactional FailureHandlingKind = "textOnly...
  constant FailureHandlingKindUndo (line 136) | FailureHandlingKindUndo FailureHandlingKind = "undo"
  type WorkspaceClientCapabilitiesWorkspaceEditChangeAnnotationSupport (line 142) | type WorkspaceClientCapabilitiesWorkspaceEditChangeAnnotationSupport struct
  type DidChangeConfigurationWorkspaceClientCapabilities (line 152) | type DidChangeConfigurationWorkspaceClientCapabilities struct
  type DidChangeWatchedFilesWorkspaceClientCapabilities (line 160) | type DidChangeWatchedFilesWorkspaceClientCapabilities struct
  type WorkspaceSymbolClientCapabilities (line 169) | type WorkspaceSymbolClientCapabilities struct
  type SymbolKindCapabilities (line 183) | type SymbolKindCapabilities struct
  type TagSupportCapabilities (line 195) | type TagSupportCapabilities struct
  type ExecuteCommandClientCapabilities (line 201) | type ExecuteCommandClientCapabilities struct
  type SemanticTokensWorkspaceClientCapabilities (line 209) | type SemanticTokensWorkspaceClientCapabilities struct
  type CodeLensWorkspaceClientCapabilities (line 223) | type CodeLensWorkspaceClientCapabilities struct
  type WorkspaceClientCapabilitiesFileOperations (line 237) | type WorkspaceClientCapabilitiesFileOperations struct
  type TextDocumentClientCapabilities (line 262) | type TextDocumentClientCapabilities struct
  type TextDocumentSyncClientCapabilities (line 364) | type TextDocumentSyncClientCapabilities struct
  type CompletionTextDocumentClientCapabilities (line 381) | type CompletionTextDocumentClientCapabilities struct
  type CompletionTextDocumentClientCapabilitiesItem (line 398) | type CompletionTextDocumentClientCapabilitiesItem struct
  type CompletionTextDocumentClientCapabilitiesItemTagSupport (line 453) | type CompletionTextDocumentClientCapabilitiesItemTagSupport struct
  type CompletionTextDocumentClientCapabilitiesItemResolveSupport (line 463) | type CompletionTextDocumentClientCapabilitiesItemResolveSupport struct
  type CompletionTextDocumentClientCapabilitiesItemInsertTextModeSupport (line 471) | type CompletionTextDocumentClientCapabilitiesItemInsertTextModeSupport s...
  type CompletionTextDocumentClientCapabilitiesItemKind (line 479) | type CompletionTextDocumentClientCapabilitiesItemKind struct
  type HoverTextDocumentClientCapabilities (line 493) | type HoverTextDocumentClientCapabilities struct
  type SignatureHelpTextDocumentClientCapabilities (line 503) | type SignatureHelpTextDocumentClientCapabilities struct
  type TextDocumentClientCapabilitiesSignatureInformation (line 521) | type TextDocumentClientCapabilitiesSignatureInformation struct
  type TextDocumentClientCapabilitiesParameterInformation (line 537) | type TextDocumentClientCapabilitiesParameterInformation struct
  type DeclarationTextDocumentClientCapabilities (line 546) | type DeclarationTextDocumentClientCapabilities struct
  type DefinitionTextDocumentClientCapabilities (line 561) | type DefinitionTextDocumentClientCapabilities struct
  type TypeDefinitionTextDocumentClientCapabilities (line 572) | type TypeDefinitionTextDocumentClientCapabilities struct
  type ImplementationTextDocumentClientCapabilities (line 587) | type ImplementationTextDocumentClientCapabilities struct
  type ReferencesTextDocumentClientCapabilities (line 600) | type ReferencesTextDocumentClientCapabilities struct
  type DocumentHighlightClientCapabilities (line 606) | type DocumentHighlightClientCapabilities struct
  type DocumentSymbolClientCapabilities (line 612) | type DocumentSymbolClientCapabilities struct
  type DocumentSymbolClientCapabilitiesTagSupport (line 639) | type DocumentSymbolClientCapabilitiesTagSupport struct
  type CodeActionClientCapabilities (line 645) | type CodeActionClientCapabilities struct
  type CodeActionClientCapabilitiesLiteralSupport (line 689) | type CodeActionClientCapabilitiesLiteralSupport struct
  type CodeActionClientCapabilitiesKind (line 696) | type CodeActionClientCapabilitiesKind struct
  type CodeActionClientCapabilitiesResolveSupport (line 707) | type CodeActionClientCapabilitiesResolveSupport struct
  type CodeLensClientCapabilities (line 713) | type CodeLensClientCapabilities struct
  type DocumentLinkClientCapabilities (line 719) | type DocumentLinkClientCapabilities struct
  type DocumentColorClientCapabilities (line 733) | type DocumentColorClientCapabilities struct
  type DocumentFormattingClientCapabilities (line 741) | type DocumentFormattingClientCapabilities struct
  type DocumentRangeFormattingClientCapabilities (line 747) | type DocumentRangeFormattingClientCapabilities struct
  type DocumentOnTypeFormattingClientCapabilities (line 753) | type DocumentOnTypeFormattingClientCapabilities struct
  type PublishDiagnosticsClientCapabilities (line 759) | type PublishDiagnosticsClientCapabilities struct
  type PublishDiagnosticsClientCapabilitiesTagSupport (line 790) | type PublishDiagnosticsClientCapabilitiesTagSupport struct
  type RenameClientCapabilities (line 796) | type RenameClientCapabilities struct
  type PrepareSupportDefaultBehavior (line 826) | type PrepareSupportDefaultBehavior
    method String (line 836) | func (k PrepareSupportDefaultBehavior) String() string {
  constant PrepareSupportDefaultBehaviorIdentifier (line 832) | PrepareSupportDefaultBehaviorIdentifier PrepareSupportDefaultBehavior = 1
  type FoldingRangeClientCapabilities (line 848) | type FoldingRangeClientCapabilities struct
  type SelectionRangeClientCapabilities (line 866) | type SelectionRangeClientCapabilities struct
  type CallHierarchyClientCapabilities (line 876) | type CallHierarchyClientCapabilities struct
  type SemanticTokensClientCapabilities (line 887) | type SemanticTokensClientCapabilities struct
  type SemanticTokensWorkspaceClientCapabilitiesRequests (line 923) | type SemanticTokensWorkspaceClientCapabilitiesRequests struct
  type LinkedEditingRangeClientCapabilities (line 938) | type LinkedEditingRangeClientCapabilities struct
  type MonikerClientCapabilities (line 949) | type MonikerClientCapabilities struct
  type WindowClientCapabilities (line 960) | type WindowClientCapabilities struct
  type ShowMessageRequestClientCapabilities (line 981) | type ShowMessageRequestClientCapabilities struct
  type ShowMessageRequestClientCapabilitiesMessageActionItem (line 989) | type ShowMessageRequestClientCapabilitiesMessageActionItem struct
  type ShowDocumentClientCapabilities (line 999) | type ShowDocumentClientCapabilities struct
  type GeneralClientCapabilities (line 1008) | type GeneralClientCapabilities struct
  type RegularExpressionsClientCapabilities (line 1043) | type RegularExpressionsClientCapabilities struct
  type MarkdownClientCapabilities (line 1062) | type MarkdownClientCapabilities struct

FILE: lsp/protocol/capabilities_client_test.go
  function TestClientCapabilities (line 13) | func TestClientCapabilities(t *testing.T) {
  function TestWorkspaceClientCapabilities (line 312) | func TestWorkspaceClientCapabilities(t *testing.T) {
  function TestWorkspaceClientCapabilitiesWorkspaceEdit (line 441) | func TestWorkspaceClientCapabilitiesWorkspaceEdit(t *testing.T) {
  function TestTextDocumentClientCapabilities (line 547) | func TestTextDocumentClientCapabilities(t *testing.T) {
  function TestTextDocumentSyncClientCapabilities (line 790) | func TestTextDocumentSyncClientCapabilities(t *testing.T) {
  function TestCompletionTextDocumentClientCapabilities (line 891) | func TestCompletionTextDocumentClientCapabilities(t *testing.T) {
  function TestHoverTextDocumentClientCapabilities (line 1018) | func TestHoverTextDocumentClientCapabilities(t *testing.T) {
  function TestSignatureHelpTextDocumentClientCapabilities (line 1120) | func TestSignatureHelpTextDocumentClientCapabilities(t *testing.T) {
  function TestDeclarationTextDocumentClientCapabilities (line 1229) | func TestDeclarationTextDocumentClientCapabilities(t *testing.T) {
  function TestDefinitionTextDocumentClientCapabilities (line 1328) | func TestDefinitionTextDocumentClientCapabilities(t *testing.T) {
  function TestTypeDefinitionTextDocumentClientCapabilities (line 1427) | func TestTypeDefinitionTextDocumentClientCapabilities(t *testing.T) {
  function TestImplementationTextDocumentClientCapabilities (line 1526) | func TestImplementationTextDocumentClientCapabilities(t *testing.T) {
  function TestReferencesTextDocumentClientCapabilities (line 1625) | func TestReferencesTextDocumentClientCapabilities(t *testing.T) {
  function TestDocumentHighlightClientCapabilities (line 1723) | func TestDocumentHighlightClientCapabilities(t *testing.T) {
  function TestDocumentSymbolClientCapabilities (line 1821) | func TestDocumentSymbolClientCapabilities(t *testing.T) {
  function TestCodeActionClientCapabilities (line 1936) | func TestCodeActionClientCapabilities(t *testing.T) {
  function TestCodeLensClientCapabilities (line 2053) | func TestCodeLensClientCapabilities(t *testing.T) {
  function TestDocumentLinkClientCapabilities (line 2151) | func TestDocumentLinkClientCapabilities(t *testing.T) {
  function TestDocumentColorClientCapabilities (line 2250) | func TestDocumentColorClientCapabilities(t *testing.T) {
  function TestPublishDiagnosticsClientCapabilities (line 2348) | func TestPublishDiagnosticsClientCapabilities(t *testing.T) {
  function TestRenameClientCapabilities (line 2455) | func TestRenameClientCapabilities(t *testing.T) {
  function TestFoldingRangeClientCapabilities (line 2556) | func TestFoldingRangeClientCapabilities(t *testing.T) {
  function TestSemanticTokensClientCapabilities (line 2656) | func TestSemanticTokensClientCapabilities(t *testing.T) {

FILE: lsp/protocol/capabilities_server.go
  type ServerCapabilities (line 11) | type ServerCapabilities struct
  type TextDocumentSyncOptions (line 130) | type TextDocumentSyncOptions struct
  type SaveOptions (line 149) | type SaveOptions struct
  type TextDocumentSyncKind (line 155) | type TextDocumentSyncKind
    method String (line 172) | func (k TextDocumentSyncKind) String() string {
  constant TextDocumentSyncKindNone (line 159) | TextDocumentSyncKindNone TextDocumentSyncKind = 0
  constant TextDocumentSyncKindFull (line 163) | TextDocumentSyncKindFull TextDocumentSyncKind = 1
  constant TextDocumentSyncKindIncremental (line 168) | TextDocumentSyncKindIncremental TextDocumentSyncKind = 2
  type CompletionOptions (line 186) | type CompletionOptions struct
  type HoverOptions (line 196) | type HoverOptions struct
  type SignatureHelpOptions (line 201) | type SignatureHelpOptions struct
  type DeclarationOptions (line 219) | type DeclarationOptions struct
  type DeclarationRegistrationOptions (line 226) | type DeclarationRegistrationOptions struct
  type DefinitionOptions (line 235) | type DefinitionOptions struct
  type TypeDefinitionOptions (line 242) | type TypeDefinitionOptions struct
  type TypeDefinitionRegistrationOptions (line 249) | type TypeDefinitionRegistrationOptions struct
  type ImplementationOptions (line 258) | type ImplementationOptions struct
  type ImplementationRegistrationOptions (line 265) | type ImplementationRegistrationOptions struct
  type ReferenceOptions (line 272) | type ReferenceOptions struct
  type DocumentHighlightOptions (line 279) | type DocumentHighlightOptions struct
  type DocumentSymbolOptions (line 286) | type DocumentSymbolOptions struct
  type CodeActionOptions (line 297) | type CodeActionOptions struct
  type CodeLensOptions (line 312) | type CodeLensOptions struct
  type DocumentLinkOptions (line 318) | type DocumentLinkOptions struct
  type DocumentColorOptions (line 326) | type DocumentColorOptions struct
  type DocumentColorRegistrationOptions (line 333) | type DocumentColorRegistrationOptions struct
  type WorkspaceSymbolOptions (line 342) | type WorkspaceSymbolOptions struct
  type DocumentFormattingOptions (line 349) | type DocumentFormattingOptions struct
  type DocumentRangeFormattingOptions (line 356) | type DocumentRangeFormattingOptions struct
  type DocumentOnTypeFormattingOptions (line 361) | type DocumentOnTypeFormattingOptions struct
  type RenameOptions (line 370) | type RenameOptions struct
  type FoldingRangeOptions (line 378) | type FoldingRangeOptions struct
  type FoldingRangeRegistrationOptions (line 385) | type FoldingRangeRegistrationOptions struct
  type ExecuteCommandOptions (line 392) | type ExecuteCommandOptions struct
  type CallHierarchyOptions (line 400) | type CallHierarchyOptions struct
  type CallHierarchyRegistrationOptions (line 407) | type CallHierarchyRegistrationOptions struct
  type LinkedEditingRangeOptions (line 416) | type LinkedEditingRangeOptions struct
  type LinkedEditingRangeRegistrationOptions (line 423) | type LinkedEditingRangeRegistrationOptions struct
  type SemanticTokensOptions (line 432) | type SemanticTokensOptions struct
  type SemanticTokensRegistrationOptions (line 439) | type SemanticTokensRegistrationOptions struct
  type ServerCapabilitiesWorkspace (line 446) | type ServerCapabilitiesWorkspace struct
  type ServerCapabilitiesWorkspaceFolders (line 461) | type ServerCapabilitiesWorkspaceFolders struct
  type ServerCapabilitiesWorkspaceFileOperations (line 478) | type ServerCapabilitiesWorkspaceFileOperations struct
  type FileOperationRegistrationOptions (line 505) | type FileOperationRegistrationOptions struct
  type MonikerOptions (line 513) | type MonikerOptions struct
  type MonikerRegistrationOptions (line 520) | type MonikerRegistrationOptions struct

FILE: lsp/protocol/client.go
  function ClientDispatcher (line 20) | func ClientDispatcher(conn jsonrpc2.Conn, logger *slog.Logger) Client {
  function ClientHandler (line 28) | func ClientHandler(log *slog.Logger, client Client, handler jsonrpc2.Han...
  function clientDispatch (line 50) | func clientDispatch(ctx context.Context, log *slog.Logger, client Client...
  type Client (line 207) | type Client interface
  constant MethodProgress (line 225) | MethodProgress = "$/progress"
  constant MethodWorkDoneProgressCreate (line 228) | MethodWorkDoneProgressCreate = "window/workDoneProgress/create"
  constant MethodWindowShowMessage (line 231) | MethodWindowShowMessage = "window/showMessage"
  constant MethodWindowShowMessageRequest (line 234) | MethodWindowShowMessageRequest = "window/showMessageRequest"
  constant MethodWindowLogMessage (line 237) | MethodWindowLogMessage = "window/logMessage"
  constant MethodTelemetryEvent (line 240) | MethodTelemetryEvent = "telemetry/event"
  constant MethodClientRegisterCapability (line 243) | MethodClientRegisterCapability = "client/registerCapability"
  constant MethodClientUnregisterCapability (line 246) | MethodClientUnregisterCapability = "client/unregisterCapability"
  constant MethodTextDocumentPublishDiagnostics (line 249) | MethodTextDocumentPublishDiagnostics = "textDocument/publishDiagnostics"
  constant MethodWorkspaceApplyEdit (line 252) | MethodWorkspaceApplyEdit = "workspace/applyEdit"
  constant MethodWorkspaceConfiguration (line 255) | MethodWorkspaceConfiguration = "workspace/configuration"
  constant MethodWorkspaceWorkspaceFolders (line 258) | MethodWorkspaceWorkspaceFolders = "workspace/workspaceFolders"
  type client (line 262) | type client struct
    method Progress (line 277) | func (c *client) Progress(ctx context.Context, params *ProgressParams)...
    method WorkDoneProgressCreate (line 287) | func (c *client) WorkDoneProgressCreate(ctx context.Context, params *W...
    method LogMessage (line 295) | func (c *client) LogMessage(ctx context.Context, params *LogMessagePar...
    method PublishDiagnostics (line 312) | func (c *client) PublishDiagnostics(ctx context.Context, params *Publi...
    method ShowMessage (line 321) | func (c *client) ShowMessage(ctx context.Context, params *ShowMessageP...
    method ShowMessageRequest (line 328) | func (c *client) ShowMessageRequest(ctx context.Context, params *ShowM...
    method Telemetry (line 341) | func (c *client) Telemetry(ctx context.Context, params any) (err error) {
    method RegisterCapability (line 354) | func (c *client) RegisterCapability(ctx context.Context, params *Regis...
    method UnregisterCapability (line 362) | func (c *client) UnregisterCapability(ctx context.Context, params *Unr...
    method ApplyEdit (line 370) | func (c *client) ApplyEdit(ctx context.Context, params *ApplyWorkspace...
    method Configuration (line 386) | func (c *client) Configuration(ctx context.Context, params *Configurat...
    method WorkspaceFolders (line 403) | func (c *client) WorkspaceFolders(ctx context.Context) (result []Works...

FILE: lsp/protocol/context.go
  type ctxClientKey (line 10) | type ctxClientKey
  function WithClient (line 15) | func WithClient(ctx context.Context, client Client) context.Context {
  function ClientFromContext (line 20) | func ClientFromContext(ctx context.Context) Client {

FILE: lsp/protocol/deprecated.go
  constant Abort (line 209) | Abort = FailureHandlingKindAbort
  constant TextOnlyTransactional (line 214) | TextOnlyTransactional = FailureHandlingKindTextOnlyTransactional
  constant Transactional (line 219) | Transactional = FailureHandlingKindTransactional
  constant Undo (line 224) | Undo = FailureHandlingKindUndo

FILE: lsp/protocol/diagnostics.go
  type Diagnostic (line 13) | type Diagnostic struct
  type DiagnosticSeverity (line 54) | type DiagnosticSeverity
    method String (line 71) | func (d DiagnosticSeverity) String() string {
  constant DiagnosticSeverityError (line 58) | DiagnosticSeverityError DiagnosticSeverity = 1
  constant DiagnosticSeverityWarning (line 61) | DiagnosticSeverityWarning DiagnosticSeverity = 2
  constant DiagnosticSeverityInformation (line 64) | DiagnosticSeverityInformation DiagnosticSeverity = 3
  constant DiagnosticSeverityHint (line 67) | DiagnosticSeverityHint DiagnosticSeverity = 4
  type CodeDescription (line 89) | type CodeDescription struct
  type DiagnosticTag (line 97) | type DiagnosticTag
    method String (line 114) | func (d DiagnosticTag) String() string {
  constant DiagnosticTagUnnecessary (line 105) | DiagnosticTagUnnecessary DiagnosticTag = 1
  constant DiagnosticTagDeprecated (line 110) | DiagnosticTagDeprecated DiagnosticTag = 2
  type DiagnosticRelatedInformation (line 129) | type DiagnosticRelatedInformation struct
  type PublishDiagnosticsParams (line 138) | type PublishDiagnosticsParams struct

FILE: lsp/protocol/diagnostics_test.go
  function TestDiagnostic (line 15) | func TestDiagnostic(t *testing.T) {
  function TestDiagnosticSeverity_String (line 317) | func TestDiagnosticSeverity_String(t *testing.T) {
  function TestDiagnosticTag_String (line 363) | func TestDiagnosticTag_String(t *testing.T) {
  function TestDiagnosticRelatedInformation (line 399) | func TestDiagnosticRelatedInformation(t *testing.T) {
  function TestPublishDiagnosticsParams (line 508) | func TestPublishDiagnosticsParams(t *testing.T) {

FILE: lsp/protocol/errors.go
  constant LSPReservedErrorRangeStart (line 14) | LSPReservedErrorRangeStart jsonrpc2.Code = -32899
  constant CodeContentModified (line 19) | CodeContentModified jsonrpc2.Code = -32801
  constant CodeRequestCancelled (line 24) | CodeRequestCancelled jsonrpc2.Code = -32800
  constant LSPReservedErrorRangeEnd (line 31) | LSPReservedErrorRangeEnd jsonrpc2.Code = -32800

FILE: lsp/protocol/general.go
  type TraceValue (line 7) | type TraceValue
  constant TraceOff (line 12) | TraceOff TraceValue = "off"
  constant TraceMessage (line 15) | TraceMessage TraceValue = "message"
  constant TraceVerbose (line 18) | TraceVerbose TraceValue = "verbose"
  type ClientInfo (line 24) | type ClientInfo struct
  type InitializeParams (line 33) | type InitializeParams struct
  type InitializeResult (line 88) | type InitializeResult struct
  type LogTraceParams (line 101) | type LogTraceParams struct
  type SetTraceParams (line 113) | type SetTraceParams struct
  type FileOperationPatternKind (line 122) | type FileOperationPatternKind
  constant FileOperationPatternKindFile (line 127) | FileOperationPatternKindFile FileOperationPatternKind = "file"
  constant FileOperationPatternKindFolder (line 130) | FileOperationPatternKindFolder FileOperationPatternKind = "folder"
  type FileOperationPatternOptions (line 136) | type FileOperationPatternOptions struct
  type FileOperationPattern (line 145) | type FileOperationPattern struct
  type FileOperationFilter (line 172) | type FileOperationFilter struct
  type CreateFilesParams (line 184) | type CreateFilesParams struct
  type FileCreate (line 192) | type FileCreate struct
  type RenameFilesParams (line 201) | type RenameFilesParams struct
  type FileRename (line 210) | type FileRename struct
  type DeleteFilesParams (line 222) | type DeleteFilesParams struct
  type FileDelete (line 230) | type FileDelete struct
  type DocumentHighlightParams (line 238) | type DocumentHighlightParams struct
  type DeclarationParams (line 247) | type DeclarationParams struct
  type DefinitionParams (line 256) | type DefinitionParams struct
  type TypeDefinitionParams (line 265) | type TypeDefinitionParams struct
  type ImplementationParams (line 274) | type ImplementationParams struct
  type ShowDocumentParams (line 283) | type ShowDocumentParams struct
  type ShowDocumentResult (line 308) | type ShowDocumentResult struct
  type ServerInfo (line 316) | type ServerInfo struct
  type InitializeError (line 325) | type InitializeError struct
  type ReferencesOptions (line 336) | type ReferencesOptions struct
  type WorkDoneProgressOptions (line 343) | type WorkDoneProgressOptions struct
  type LinkedEditingRangeParams (line 350) | type LinkedEditingRangeParams struct
  type LinkedEditingRanges (line 358) | type LinkedEditingRanges struct
  type MonikerParams (line 376) | type MonikerParams struct
  type UniquenessLevel (line 385) | type UniquenessLevel
  constant UniquenessLevelDocument (line 390) | UniquenessLevelDocument UniquenessLevel = "document"
  constant UniquenessLevelProject (line 393) | UniquenessLevelProject UniquenessLevel = "project"
  constant UniquenessLevelGroup (line 396) | UniquenessLevelGroup UniquenessLevel = "group"
  constant UniquenessLevelScheme (line 399) | UniquenessLevelScheme UniquenessLevel = "scheme"
  constant UniquenessLevelGlobal (line 402) | UniquenessLevelGlobal UniquenessLevel = "global"
  type MonikerKind (line 408) | type MonikerKind
  constant MonikerKindImport (line 413) | MonikerKindImport MonikerKind = "import"
  constant MonikerKindExport (line 416) | MonikerKindExport MonikerKind = "export"
  constant MonikerKindLocal (line 420) | MonikerKindLocal MonikerKind = "local"
  type Moniker (line 426) | type Moniker struct
  type StaticRegistrationOptions (line 443) | type StaticRegistrationOptions struct
  type DocumentLinkRegistrationOptions (line 450) | type DocumentLinkRegistrationOptions struct
  type InitializedParams (line 458) | type InitializedParams struct
  type WorkspaceFolders (line 461) | type WorkspaceFolders

FILE: lsp/protocol/general_test.go
  function TestWorkspaceFolders (line 18) | func TestWorkspaceFolders(t *testing.T) {
  function TestClientInfo (line 106) | func TestClientInfo(t *testing.T) {
  function TestInitializeParams (line 208) | func TestInitializeParams(t *testing.T) {
  function TestLogTraceParams (line 341) | func TestLogTraceParams(t *testing.T) {
  function TestSetTraceParams (line 443) | func TestSetTraceParams(t *testing.T) {
  function TestCreateFilesParams (line 541) | func TestCreateFilesParams(t *testing.T) {
  function TestRenameFilesParams (line 643) | func TestRenameFilesParams(t *testing.T) {
  function TestDeleteFilesParams (line 746) | func TestDeleteFilesParams(t *testing.T) {
  function TestReferencesParams (line 848) | func TestReferencesParams(t *testing.T) {
  function TestDocumentHighlightOptions (line 1008) | func TestDocumentHighlightOptions(t *testing.T) {
  function TestDocumentHighlightParams (line 1123) | func TestDocumentHighlightParams(t *testing.T) {
  function TestDocumentSymbolOptions (line 1277) | func TestDocumentSymbolOptions(t *testing.T) {
  function TestWorkspaceSymbolOptions (line 1393) | func TestWorkspaceSymbolOptions(t *testing.T) {
  function TestDocumentFormattingOptions (line 1508) | func TestDocumentFormattingOptions(t *testing.T) {
  function TestDocumentRangeFormattingOptions (line 1623) | func TestDocumentRangeFormattingOptions(t *testing.T) {
  function TestDeclarationOptions (line 1738) | func TestDeclarationOptions(t *testing.T) {
  function TestDeclarationRegistrationOptions (line 1853) | func TestDeclarationRegistrationOptions(t *testing.T) {
  function TestDeclarationParams (line 1993) | func TestDeclarationParams(t *testing.T) {
  function TestDefinitionOptions (line 2147) | func TestDefinitionOptions(t *testing.T) {
  function TestDefinitionParams (line 2262) | func TestDefinitionParams(t *testing.T) {
  function TestTypeDefinitionOptions (line 2416) | func TestTypeDefinitionOptions(t *testing.T) {
  function TestTypeDefinitionRegistrationOptions (line 2531) | func TestTypeDefinitionRegistrationOptions(t *testing.T) {
  function TestTypeDefinitionParams (line 2671) | func TestTypeDefinitionParams(t *testing.T) {
  function TestImplementationOptions (line 2825) | func TestImplementationOptions(t *testing.T) {
  function TestImplementationRegistrationOptions (line 2926) | func TestImplementationRegistrationOptions(t *testing.T) {
  function TestImplementationParams (line 3066) | func TestImplementationParams(t *testing.T) {
  function TestDocumentColorOptions (line 3220) | func TestDocumentColorOptions(t *testing.T) {
  function TestDocumentColorRegistrationOptions (line 3335) | func TestDocumentColorRegistrationOptions(t *testing.T) {
  function TestPrepareSupportDefaultBehavior_String (line 3475) | func TestPrepareSupportDefaultBehavior_String(t *testing.T) {
  function TestFoldingRangeOptions (line 3506) | func TestFoldingRangeOptions(t *testing.T) {
  function TestFoldingRangeRegistrationOptions (line 3621) | func TestFoldingRangeRegistrationOptions(t *testing.T) {
  function TestInitializeResult (line 3761) | func TestInitializeResult(t *testing.T) {
  function TestInitializeError (line 4013) | func TestInitializeError(t *testing.T) {
  function TestShowDocumentParams (line 4094) | func TestShowDocumentParams(t *testing.T) {
  function TestShowDocumentResult (line 4207) | func TestShowDocumentResult(t *testing.T) {
  function TestTextDocumentSyncKind_String (line 4288) | func TestTextDocumentSyncKind_String(t *testing.T) {
  function TestReferencesOptions (line 4329) | func TestReferencesOptions(t *testing.T) {
  function TestCodeActionOptions (line 4412) | func TestCodeActionOptions(t *testing.T) {
  function TestRenameOptions (line 4515) | func TestRenameOptions(t *testing.T) {
  function TestSaveOptions (line 4614) | func TestSaveOptions(t *testing.T) {
  function TestTextDocumentSyncOptions (line 4713) | func TestTextDocumentSyncOptions(t *testing.T) {
  function TestHoverOptions (line 4818) | func TestHoverOptions(t *testing.T) {
  function TestStaticRegistrationOptions (line 4919) | func TestStaticRegistrationOptions(t *testing.T) {
  function TestDocumentLinkRegistrationOptions (line 5018) | func TestDocumentLinkRegistrationOptions(t *testing.T) {
  function TestInitializedParams (line 5130) | func TestInitializedParams(t *testing.T) {

FILE: lsp/protocol/handler.go
  function CancelHandler (line 17) | func CancelHandler(handler jsonrpc2.Handler) jsonrpc2.Handler {
  function Handlers (line 62) | func Handlers(handler jsonrpc2.Handler) jsonrpc2.Handler {
  function Call (line 71) | func Call(ctx context.Context, conn jsonrpc2.Conn, method string, params...
  function notifyCancel (line 80) | func notifyCancel(ctx context.Context, conn jsonrpc2.Conn, id jsonrpc2.I...
  function replyParseError (line 86) | func replyParseError(ctx context.Context, reply jsonrpc2.Replier, err er...

FILE: lsp/protocol/language.go
  type CompletionParams (line 13) | type CompletionParams struct
  type CompletionTriggerKind (line 24) | type CompletionTriggerKind
    method String (line 40) | func (k CompletionTriggerKind) String() string {
  constant CompletionTriggerKindInvoked (line 29) | CompletionTriggerKindInvoked CompletionTriggerKind = 1
  constant CompletionTriggerKindTriggerCharacter (line 33) | CompletionTriggerKindTriggerCharacter CompletionTriggerKind = 2
  constant CompletionTriggerKindTriggerForIncompleteCompletions (line 36) | CompletionTriggerKindTriggerForIncompleteCompletions CompletionTriggerKi...
  type CompletionContext (line 54) | type CompletionContext struct
  type CompletionList (line 65) | type CompletionList struct
  type InsertTextFormat (line 76) | type InsertTextFormat
    method String (line 92) | func (tf InsertTextFormat) String() string {
  constant InsertTextFormatPlainText (line 80) | InsertTextFormatPlainText InsertTextFormat = 1
  constant InsertTextFormatSnippet (line 88) | InsertTextFormatSnippet InsertTextFormat = 2
  type InsertReplaceEdit (line 106) | type InsertReplaceEdit struct
  type InsertTextMode (line 121) | type InsertTextMode
    method String (line 142) | func (k InsertTextMode) String() string {
  constant InsertTextModeAsIs (line 129) | InsertTextModeAsIs InsertTextMode = 1
  constant InsertTextModeAdjustIndentation (line 138) | InsertTextModeAdjustIndentation InsertTextMode = 2
  type CompletionItem (line 154) | type CompletionItem struct
  type TextEditOrInsertReplaceEdit (line 265) | type TextEditOrInsertReplaceEdit struct
    method MarshalJSON (line 270) | func (t *TextEditOrInsertReplaceEdit) MarshalJSON() ([]byte, error) {
    method UnmarshalJSON (line 290) | func (t *TextEditOrInsertReplaceEdit) UnmarshalJSON(data []byte) error {
  type textEditAndInsertReplaceEdit (line 277) | type textEditAndInsertReplaceEdit struct
  type CompletionItemKind (line 318) | type CompletionItemKind
    method String (line 376) | func (k CompletionItemKind) String() string {
  constant CompletionItemKindText (line 322) | CompletionItemKindText CompletionItemKind = 1
  constant CompletionItemKindMethod (line 324) | CompletionItemKindMethod CompletionItemKind = 2
  constant CompletionItemKindFunction (line 326) | CompletionItemKindFunction CompletionItemKind = 3
  constant CompletionItemKindConstructor (line 328) | CompletionItemKindConstructor CompletionItemKind = 4
  constant CompletionItemKindField (line 330) | CompletionItemKindField CompletionItemKind = 5
  constant CompletionItemKindVariable (line 332) | CompletionItemKindVariable CompletionItemKind = 6
  constant CompletionItemKindClass (line 334) | CompletionItemKindClass CompletionItemKind = 7
  constant CompletionItemKindInterface (line 336) | CompletionItemKindInterface CompletionItemKind = 8
  constant CompletionItemKindModule (line 338) | CompletionItemKindModule CompletionItemKind = 9
  constant CompletionItemKindProperty (line 340) | CompletionItemKindProperty CompletionItemKind = 10
  constant CompletionItemKindUnit (line 342) | CompletionItemKindUnit CompletionItemKind = 11
  constant CompletionItemKindValue (line 344) | CompletionItemKindValue CompletionItemKind = 12
  constant CompletionItemKindEnum (line 346) | CompletionItemKindEnum CompletionItemKind = 13
  constant CompletionItemKindKeyword (line 348) | CompletionItemKindKeyword CompletionItemKind = 14
  constant CompletionItemKindSnippet (line 350) | CompletionItemKindSnippet CompletionItemKind = 15
  constant CompletionItemKindColor (line 352) | CompletionItemKindColor CompletionItemKind = 16
  constant CompletionItemKindFile (line 354) | CompletionItemKindFile CompletionItemKind = 17
  constant CompletionItemKindReference (line 356) | CompletionItemKindReference CompletionItemKind = 18
  constant CompletionItemKindFolder (line 358) | CompletionItemKindFolder CompletionItemKind = 19
  constant CompletionItemKindEnumMember (line 360) | CompletionItemKindEnumMember CompletionItemKind = 20
  constant CompletionItemKindConstant (line 362) | CompletionItemKindConstant CompletionItemKind = 21
  constant CompletionItemKindStruct (line 364) | CompletionItemKindStruct CompletionItemKind = 22
  constant CompletionItemKindEvent (line 366) | CompletionItemKindEvent CompletionItemKind = 23
  constant CompletionItemKindOperator (line 368) | CompletionItemKindOperator CompletionItemKind = 24
  constant CompletionItemKindTypeParameter (line 370) | CompletionItemKindTypeParameter CompletionItemKind = 25
  type CompletionItemTag (line 437) | type CompletionItemTag
    method String (line 446) | func (c CompletionItemTag) String() string {
  constant CompletionItemTagDeprecated (line 442) | CompletionItemTagDeprecated CompletionItemTag = 1
  type CompletionRegistrationOptions (line 456) | type CompletionRegistrationOptions struct
  type HoverParams (line 477) | type HoverParams struct
  type Hover (line 483) | type Hover struct
  type SignatureHelpParams (line 495) | type SignatureHelpParams struct
  type SignatureHelpTriggerKind (line 511) | type SignatureHelpTriggerKind
    method String (line 527) | func (s SignatureHelpTriggerKind) String() string {
  constant SignatureHelpTriggerKindInvoked (line 516) | SignatureHelpTriggerKindInvoked SignatureHelpTriggerKind = 1
  constant SignatureHelpTriggerKindTriggerCharacter (line 519) | SignatureHelpTriggerKindTriggerCharacter SignatureHelpTriggerKind = 2
  constant SignatureHelpTriggerKindContentChange (line 523) | SignatureHelpTriggerKindContentChange SignatureHelpTriggerKind = 3
  type SignatureHelpContext (line 544) | type SignatureHelpContext struct
  type SignatureHelp (line 571) | type SignatureHelp struct
  type SignatureInformation (line 596) | type SignatureInformation struct
  type ParameterInformation (line 623) | type ParameterInformation struct
  type SignatureHelpRegistrationOptions (line 640) | type SignatureHelpRegistrationOptions struct
  type ReferenceParams (line 651) | type ReferenceParams struct
  type ReferenceContext (line 661) | type ReferenceContext struct
  type DocumentHighlight (line 669) | type DocumentHighlight struct
  type DocumentHighlightKind (line 678) | type DocumentHighlightKind
    method String (line 692) | func (k DocumentHighlightKind) String() string {
  constant DocumentHighlightKindText (line 682) | DocumentHighlightKindText DocumentHighlightKind = 1
  constant DocumentHighlightKindRead (line 685) | DocumentHighlightKindRead DocumentHighlightKind = 2
  constant DocumentHighlightKindWrite (line 688) | DocumentHighlightKindWrite DocumentHighlightKind = 3
  type DocumentSymbolParams (line 706) | type DocumentSymbolParams struct
  type SymbolKind (line 723) | type SymbolKind
    method String (line 783) | func (k SymbolKind) String() string {
  constant SymbolKindFile (line 727) | SymbolKindFile SymbolKind = 1
  constant SymbolKindModule (line 729) | SymbolKindModule SymbolKind = 2
  constant SymbolKindNamespace (line 731) | SymbolKindNamespace SymbolKind = 3
  constant SymbolKindPackage (line 733) | SymbolKindPackage SymbolKind = 4
  constant SymbolKindClass (line 735) | SymbolKindClass SymbolKind = 5
  constant SymbolKindMethod (line 737) | SymbolKindMethod SymbolKind = 6
  constant SymbolKindProperty (line 739) | SymbolKindProperty SymbolKind = 7
  constant SymbolKindField (line 741) | SymbolKindField SymbolKind = 8
  constant SymbolKindConstructor (line 743) | SymbolKindConstructor SymbolKind = 9
  constant SymbolKindEnum (line 745) | SymbolKindEnum SymbolKind = 10
  constant SymbolKindInterface (line 747) | SymbolKindInterface SymbolKind = 11
  constant SymbolKindFunction (line 749) | SymbolKindFunction SymbolKind = 12
  constant SymbolKindVariable (line 751) | SymbolKindVariable SymbolKind = 13
  constant SymbolKindConstant (line 753) | SymbolKindConstant SymbolKind = 14
  constant SymbolKindString (line 755) | SymbolKindString SymbolKind = 15
  constant SymbolKindNumber (line 757) | SymbolKindNumber SymbolKind = 16
  constant SymbolKindBoolean (line 759) | SymbolKindBoolean SymbolKind = 17
  constant SymbolKindArray (line 761) | SymbolKindArray SymbolKind = 18
  constant SymbolKindObject (line 763) | SymbolKindObject SymbolKind = 19
  constant SymbolKindKey (line 765) | SymbolKindKey SymbolKind = 20
  constant SymbolKindNull (line 767) | SymbolKindNull SymbolKind = 21
  constant SymbolKindEnumMember (line 769) | SymbolKindEnumMember SymbolKind = 22
  constant SymbolKindStruct (line 771) | SymbolKindStruct SymbolKind = 23
  constant SymbolKindEvent (line 773) | SymbolKindEvent SymbolKind = 24
  constant SymbolKindOperator (line 775) | SymbolKindOperator SymbolKind = 25
  constant SymbolKindTypeParameter (line 777) | SymbolKindTypeParameter SymbolKind = 26
  type SymbolTag (line 845) | type SymbolTag
    method String (line 854) | func (k SymbolTag) String() string {
  constant SymbolTagDeprecated (line 850) | SymbolTagDeprecated SymbolTag = 1
  type DocumentSymbol (line 866) | type DocumentSymbol struct
  type SymbolInformation (line 900) | type SymbolInformation struct
  type SymbolInformationOrDocumentSymbol (line 933) | type SymbolInformationOrDocumentSymbol struct
    method MarshalJSON (line 938) | func (s *SymbolInformationOrDocumentSymbol) MarshalJSON() ([]byte, err...
    method UnmarshalJSON (line 945) | func (s *SymbolInformationOrDocumentSymbol) UnmarshalJSON(data []byte)...
  type CodeActionParams (line 970) | type CodeActionParams struct
  type CodeActionKind (line 988) | type CodeActionKind
  constant QuickFix (line 993) | QuickFix CodeActionKind = "quickfix"
  constant Refactor (line 996) | Refactor CodeActionKind = "refactor"
  constant RefactorExtract (line 1007) | RefactorExtract CodeActionKind = "refactor.extract"
  constant RefactorInline (line 1017) | RefactorInline CodeActionKind = "refactor.inline"
  constant RefactorRewrite (line 1029) | RefactorRewrite CodeActionKind = "refactor.rewrite"
  constant Source (line 1034) | Source CodeActionKind = "source"
  constant SourceOrganizeImports (line 1037) | SourceOrganizeImports CodeActionKind = "source.organizeImports"
  type CodeActionContext (line 1042) | type CodeActionContext struct
  type CodeAction (line 1054) | type CodeAction struct
  type CodeActionDisable (line 1112) | type CodeActionDisable struct
  type CodeActionRegistrationOptions (line 1121) | type CodeActionRegistrationOptions struct
  type CodeLensParams (line 1128) | type CodeLensParams struct
  type CodeLens (line 1141) | type CodeLens struct
  type CodeLensRegistrationOptions (line 1154) | type CodeLensRegistrationOptions struct
  type DocumentLinkParams (line 1162) | type DocumentLinkParams struct
  type DocumentLink (line 1172) | type DocumentLink struct
  type DocumentColorParams (line 1194) | type DocumentColorParams struct
  type ColorInformation (line 1203) | type ColorInformation struct
  type Color (line 1212) | type Color struct
  type ColorPresentationParams (line 1227) | type ColorPresentationParams struct
  type ColorPresentation (line 1242) | type ColorPresentation struct
  type DocumentFormattingParams (line 1258) | type DocumentFormattingParams struct
  type FormattingOptions (line 1269) | type FormattingOptions struct
  type DocumentRangeFormattingParams (line 1296) | type DocumentRangeFormattingParams struct
  type DocumentOnTypeFormattingParams (line 1310) | type DocumentOnTypeFormattingParams struct
  type DocumentOnTypeFormattingRegistrationOptions (line 1325) | type DocumentOnTypeFormattingRegistrationOptions struct
  type RenameParams (line 1336) | type RenameParams struct
  type RenameRegistrationOptions (line 1347) | type RenameRegistrationOptions struct
  type PrepareRenameParams (line 1357) | type PrepareRenameParams struct
  type FoldingRangeParams (line 1362) | type FoldingRangeParams struct
  type FoldingRangeKind (line 1368) | type FoldingRangeKind
  constant CommentFoldingRange (line 1372) | CommentFoldingRange FoldingRangeKind = "comment"
  constant ImportsFoldingRange (line 1375) | ImportsFoldingRange FoldingRangeKind = "imports"
  constant RegionFoldingRange (line 1378) | RegionFoldingRange FoldingRangeKind = "region"
  type FoldingRange (line 1384) | type FoldingRange struct

FILE: lsp/protocol/language_test.go
  function TestCompletionParams (line 19) | func TestCompletionParams(t *testing.T) {
  function TestCompletionTriggerKind_String (line 145) | func TestCompletionTriggerKind_String(t *testing.T) {
  function TestCompletionContext (line 186) | func TestCompletionContext(t *testing.T) {
  function TestCompletionList (line 279) | func TestCompletionList(t *testing.T) {
  function TestInsertTextFormat_String (line 406) | func TestInsertTextFormat_String(t *testing.T) {
  function TestInsertReplaceEdit (line 442) | func TestInsertReplaceEdit(t *testing.T) {
  function TestInsertTextMode_String (line 539) | func TestInsertTextMode_String(t *testing.T) {
  function TestCompletionItem (line 575) | func TestCompletionItem(t *testing.T) {
  function TestCompletionItemKind_String (line 937) | func TestCompletionItemKind_String(t *testing.T) {
  function TestCompletionItemTag_String (line 1088) | func TestCompletionItemTag_String(t *testing.T) {
  function TestCompletionRegistrationOptions (line 1119) | func TestCompletionRegistrationOptions(t *testing.T) {
  function TestHoverParams (line 1221) | func TestHoverParams(t *testing.T) {
  function TestHover (line 1366) | func TestHover(t *testing.T) {
  function TestSignatureHelpParams (line 1471) | func TestSignatureHelpParams(t *testing.T) {
  function TestSignatureHelpTriggerKind_String (line 1637) | func TestSignatureHelpTriggerKind_String(t *testing.T) {
  function TestSignatureHelp (line 1678) | func TestSignatureHelp(t *testing.T) {
  function TestSignatureInformation (line 1801) | func TestSignatureInformation(t *testing.T) {
  function TestParameterInformation (line 1901) | func TestParameterInformation(t *testing.T) {
  function TestSignatureHelpRegistrationOptions (line 1994) | func TestSignatureHelpRegistrationOptions(t *testing.T) {
  function TestReferenceParams (line 2095) | func TestReferenceParams(t *testing.T) {
  function TestReferenceContext (line 2198) | func TestReferenceContext(t *testing.T) {
  function TestDocumentHighlight (line 2290) | func TestDocumentHighlight(t *testing.T) {
  function TestDocumentHighlightKind_String (line 2392) | func TestDocumentHighlightKind_String(t *testing.T) {
  function TestDocumentSymbolParams (line 2433) | func TestDocumentSymbolParams(t *testing.T) {
  function TestSymbolKind_String (line 2549) | func TestSymbolKind_String(t *testing.T) {
  function TestSymbolTag_String (line 2705) | func TestSymbolTag_String(t *testing.T) {
  function TestDocumentSymbol (line 2736) | func TestDocumentSymbol(t *testing.T) {
  function TestSymbolInformation (line 2882) | func TestSymbolInformation(t *testing.T) {
  function TestCodeActionParams (line 3026) | func TestCodeActionParams(t *testing.T) {
  function TestCodeActionKind_String (line 3193) | func TestCodeActionKind_String(t *testing.T) {
  function TestCodeActionContext (line 3254) | func TestCodeActionContext(t *testing.T) {
  function TestCodeAction (line 3384) | func TestCodeAction(t *testing.T) {
  function TestCodeActionRegistrationOptions (line 3567) | func TestCodeActionRegistrationOptions(t *testing.T) {
  function TestCodeLensParams (line 3678) | func TestCodeLensParams(t *testing.T) {
  function TestCodeLens (line 3794) | func TestCodeLens(t *testing.T) {
  function TestCodeLensRegistrationOptions (line 3928) | func TestCodeLensRegistrationOptions(t *testing.T) {
  function TestDocumentLinkParams (line 4065) | func TestDocumentLinkParams(t *testing.T) {
  function TestDocumentLink (line 4182) | func TestDocumentLink(t *testing.T) {
  function TestDocumentColorParams (line 4313) | func TestDocumentColorParams(t *testing.T) {
  function TestColorInformation (line 4429) | func TestColorInformation(t *testing.T) {
  function TestColor (line 4536) | func TestColor(t *testing.T) {
  function TestColorPresentationParams (line 4631) | func TestColorPresentationParams(t *testing.T) {
  function TestColorPresentation (line 4763) | func TestColorPresentation(t *testing.T) {
  function TestDocumentFormattingParams (line 4901) | func TestDocumentFormattingParams(t *testing.T) {
  function TestFormattingOptions (line 5012) | func TestFormattingOptions(t *testing.T) {
  function TestDocumentRangeFormattingParams (line 5111) | func TestDocumentRangeFormattingParams(t *testing.T) {
  function TestDocumentOnTypeFormattingParams (line 5232) | func TestDocumentOnTypeFormattingParams(t *testing.T) {
  function TestDocumentOnTypeFormattingRegistrationOptions (line 5335) | func TestDocumentOnTypeFormattingRegistrationOptions(t *testing.T) {
  function TestRenameParams (line 5442) | func TestRenameParams(t *testing.T) {
  function TestRenameRegistrationOptions (line 5556) | func TestRenameRegistrationOptions(t *testing.T) {
  function TestPrepareRenameParams (line 5693) | func TestPrepareRenameParams(t *testing.T) {
  function TestFoldingRangeParams (line 5793) | func TestFoldingRangeParams(t *testing.T) {
  function TestFoldingRangeKind_String (line 5906) | func TestFoldingRangeKind_String(t *testing.T) {
  function TestFoldingRange (line 5947) | func TestFoldingRange(t *testing.T) {

FILE: lsp/protocol/progress.go
  type WorkDoneProgressKind (line 9) | type WorkDoneProgressKind
  constant WorkDoneProgressKindBegin (line 14) | WorkDoneProgressKindBegin WorkDoneProgressKind = "begin"
  constant WorkDoneProgressKindReport (line 17) | WorkDoneProgressKindReport WorkDoneProgressKind = "report"
  constant WorkDoneProgressKindEnd (line 20) | WorkDoneProgressKindEnd WorkDoneProgressKind = "end"
  type WorkDoneProgressBegin (line 26) | type WorkDoneProgressBegin struct
  type WorkDoneProgressReport (line 62) | type WorkDoneProgressReport struct
  type WorkDoneProgressEnd (line 93) | type WorkDoneProgressEnd struct
  type WorkDoneProgressParams (line 107) | type WorkDoneProgressParams struct
  type PartialResultParams (line 115) | type PartialResultParams struct

FILE: lsp/protocol/progress_test.go
  function TestWorkDoneProgressBegin (line 14) | func TestWorkDoneProgressBegin(t *testing.T) {
  function TestWorkDoneProgressReport (line 129) | fun
Condensed preview — 833 files, each showing path, character count, and a content snippet. Download the .json file or copy for the full structured content (3,894K chars).
[
  {
    "path": ".dockerignore",
    "chars": 30,
    "preview": ".git\nDockerfile\n.dockerignore\n"
  },
  {
    "path": ".envrc",
    "chars": 9,
    "preview": "use flake"
  },
  {
    "path": ".github/FUNDING.yml",
    "chars": 23,
    "preview": "github: [a-h, joerdav]\n"
  },
  {
    "path": ".github/ISSUE_TEMPLATE/bug_report.md",
    "chars": 1389,
    "preview": "---\nname: Bug report\nabout: Create a report to help us improve\ntitle: ''\nlabels: ''\nassignees: ''\n\n---\n\n**Before you beg"
  },
  {
    "path": ".github/copilot-instructions.md",
    "chars": 4935,
    "preview": "# Coding standards\n\n## Behaviour\n\n* Always run `go fmt` after making changes to Go code.\n* Always run unit tests after m"
  },
  {
    "path": ".github/workflows/ci.yml",
    "chars": 3432,
    "preview": "name: CI\n\non:\n  push:\n    branches: [main]\n  pull_request:\n    branches: [main]\n\npermissions:\n  contents: read\n\njobs:\n  "
  },
  {
    "path": ".github/workflows/docs.yaml",
    "chars": 1225,
    "preview": "name: Deploy Docs\n\non:\n  release:\n    types: [published]\n  workflow_dispatch:\n\npermissions:\n  contents: read\n  pages: wr"
  },
  {
    "path": ".github/workflows/flakehub-publish-tagged.yml",
    "chars": 772,
    "preview": "name: \"Publish tags to FlakeHub\"\non:\n  push:\n    tags:\n      - \"v?[0-9]+.[0-9]+.[0-9]+*\"\n  workflow_dispatch:\n    inputs"
  },
  {
    "path": ".github/workflows/release.yml",
    "chars": 856,
    "preview": "name: Release\n\non:\n  push:\n    tags:\n      - 'v*'\n  workflow_dispatch:\n\npermissions:\n   contents: write\n   packages: wri"
  },
  {
    "path": ".gitignore",
    "chars": 467,
    "preview": "# Output.\ncmd/templ/templ\n\n# Logs.\ncmd/templ/lspcmd/*log.txt\n\n# Go code coverage.\ncoverage.out\ncoverage\n\n# Mac filesyste"
  },
  {
    "path": ".goreleaser.yaml",
    "chars": 1299,
    "preview": "builds:\n  - env:\n      - CGO_ENABLED=0\n    dir: cmd/templ\n    mod_timestamp: '{{ .CommitTimestamp }}'\n    flags:\n      -"
  },
  {
    "path": ".ignore",
    "chars": 249,
    "preview": "*_templ.go\nexamples/integration-ct/static/index.js\nexamples/counter/assets/css/bulma.*\nexamples/counter/assets/js/htmx.m"
  },
  {
    "path": ".version",
    "chars": 8,
    "preview": "0.3.1002"
  },
  {
    "path": "CODE_OF_CONDUCT.md",
    "chars": 5227,
    "preview": "# Contributor Covenant Code of Conduct\n\n## Our Pledge\n\nWe as members, contributors, and leaders pledge to make participa"
  },
  {
    "path": "CONTRIBUTING.md",
    "chars": 7872,
    "preview": "# Contributing to templ\n\n## Vision\n\nEnable Go developers to build strongly typed, component-based HTML user interfaces w"
  },
  {
    "path": "LICENSE",
    "chars": 1071,
    "preview": "MIT License\n\nCopyright (c) 2021 Adrian Hesketh\n\nPermission is hereby granted, free of charge, to any person obtaining a "
  },
  {
    "path": "README.md",
    "chars": 3849,
    "preview": "![templ](https://github.com/a-h/templ/raw/main/templ.png)\n\n## An HTML templating language for Go that has great develope"
  },
  {
    "path": "SECURITY.md",
    "chars": 196,
    "preview": "# Security Policy\n\n## Supported Versions\n\nThe latest version of templ is supported.\n\n## Reporting a Vulnerability\n\nUse t"
  },
  {
    "path": "benchmarks/react/.gitignore",
    "chars": 23,
    "preview": "index.js\nnode_modules\n\n"
  },
  {
    "path": "benchmarks/react/README.md",
    "chars": 139,
    "preview": "# React benchmark\n\n## Tasks\n\n### install\n\n```\nnpm i\n```\n\n### build\n\n```sh\nnpm run build\n```\n\n### run\n\nrequires: build\n\n`"
  },
  {
    "path": "benchmarks/react/package.json",
    "chars": 412,
    "preview": "{\n  \"name\": \"react-benchmark\",\n  \"version\": \"1.0.0\",\n  \"description\": \"\",\n  \"main\": \"./src/index.jsx\",\n  \"scripts\": {\n  "
  },
  {
    "path": "benchmarks/react/src/index.jsx",
    "chars": 1081,
    "preview": "import * as React from 'react'\nimport * as Server from 'react-dom/server'\nimport Benchmark from 'benchmark';\n\nconst comp"
  },
  {
    "path": "benchmarks/templ/README.md",
    "chars": 722,
    "preview": "# templ benchmark\n\nUsed to test code generation strategies for improvements to render time.\n\n## Tasks\n\n### run\n\n```\ngo t"
  },
  {
    "path": "benchmarks/templ/data.go",
    "chars": 69,
    "preview": "package testhtml\n\ntype Person struct {\n\tName  string\n\tEmail string\n}\n"
  },
  {
    "path": "benchmarks/templ/render_test.go",
    "chars": 1945,
    "preview": "package testhtml\n\nimport (\n\t\"context\"\n\t\"html/template\"\n\t\"io\"\n\t\"strings\"\n\t\"testing\"\n\n\t_ \"embed\"\n\n\t\"github.com/a-h/templ/p"
  },
  {
    "path": "benchmarks/templ/template.templ",
    "chars": 387,
    "preview": "package testhtml\n\ntempl Render(p Person) {\n\t<div>\n\t\t<h1>{ p.Name }</h1>\n\t\t<div style=\"font-family: 'sans-serif'\" id=\"tes"
  },
  {
    "path": "benchmarks/templ/template_templ.go",
    "chars": 4767,
    "preview": "// Code generated by templ - DO NOT EDIT.\n\npackage testhtml\n\n//lint:file-ignore SA4006 This context is only used if a ne"
  },
  {
    "path": "cfg/cfg.go",
    "chars": 384,
    "preview": "// This package is inspired by the GOEXPERIMENT approach of allowing feature flags for experimenting with breaking chang"
  },
  {
    "path": "cmd/templ/fmtcmd/main.go",
    "chars": 3784,
    "preview": "package fmtcmd\n\nimport (\n\t\"bytes\"\n\t\"errors\"\n\t\"fmt\"\n\t\"io\"\n\t\"log/slog\"\n\t\"os\"\n\t\"runtime\"\n\t\"time\"\n\n\t\"github.com/a-h/templ/cm"
  },
  {
    "path": "cmd/templ/fmtcmd/main_test.go",
    "chars": 4795,
    "preview": "package fmtcmd\n\nimport (\n\t_ \"embed\"\n\t\"fmt\"\n\t\"io\"\n\t\"log/slog\"\n\t\"os\"\n\t\"path/filepath\"\n\t\"strings\"\n\t\"testing\"\n\n\t\"github.com/"
  },
  {
    "path": "cmd/templ/fmtcmd/testdata.txtar",
    "chars": 623,
    "preview": "-- a.templ --\npackage test\n\ntempl a() {\n\t<div><p class={templ.Class(\"mapped\")}>A\n</p></div>\n}\n-- a.templ --\npackage test"
  },
  {
    "path": "cmd/templ/generatecmd/cmd.go",
    "chars": 14424,
    "preview": "package generatecmd\n\nimport (\n\t\"context\"\n\t\"crypto/tls\"\n\t\"crypto/x509\"\n\t\"errors\"\n\t\"fmt\"\n\t\"io/fs\"\n\t\"log/slog\"\n\t\"net/http\"\n"
  },
  {
    "path": "cmd/templ/generatecmd/eventhandler.go",
    "chars": 10734,
    "preview": "package generatecmd\n\nimport (\n\t\"bufio\"\n\t\"bytes\"\n\t\"context\"\n\t\"crypto/sha256\"\n\t\"fmt\"\n\t\"go/format\"\n\t\"go/scanner\"\n\t\"go/token"
  },
  {
    "path": "cmd/templ/generatecmd/fatalerror.go",
    "chars": 350,
    "preview": "package generatecmd\n\ntype FatalError struct {\n\tErr error\n}\n\nfunc (e FatalError) Error() string {\n\treturn e.Err.Error()\n}"
  },
  {
    "path": "cmd/templ/generatecmd/main.go",
    "chars": 7108,
    "preview": "package generatecmd\n\nimport (\n\t\"context\"\n\t_ \"embed\"\n\t\"flag\"\n\t\"fmt\"\n\t\"io\"\n\t\"log/slog\"\n\t\"regexp\"\n\t\"runtime\"\n\n\t_ \"net/http/"
  },
  {
    "path": "cmd/templ/generatecmd/main_test.go",
    "chars": 8383,
    "preview": "package generatecmd\n\nimport (\n\t\"bytes\"\n\t\"context\"\n\t\"io\"\n\t\"os\"\n\t\"path\"\n\t\"regexp\"\n\t\"strings\"\n\t\"testing\"\n\t\"time\"\n\n\t\"github."
  },
  {
    "path": "cmd/templ/generatecmd/modcheck/modcheck.go",
    "chars": 2045,
    "preview": "package modcheck\n\nimport (\n\t\"fmt\"\n\t\"os\"\n\t\"path/filepath\"\n\n\t\"github.com/a-h/templ\"\n\t\"golang.org/x/mod/modfile\"\n\t\"golang.o"
  },
  {
    "path": "cmd/templ/generatecmd/modcheck/modcheck_test.go",
    "chars": 882,
    "preview": "package modcheck\n\nimport (\n\t\"testing\"\n\n\t\"golang.org/x/mod/modfile\"\n)\n\nfunc TestPatchGoVersion(t *testing.T) {\n\ttests := "
  },
  {
    "path": "cmd/templ/generatecmd/proxy/proxy.go",
    "chars": 9547,
    "preview": "package proxy\n\nimport (\n\t\"bytes\"\n\t\"compress/gzip\"\n\t\"fmt\"\n\t\"io\"\n\tstdlog \"log\"\n\t\"log/slog\"\n\t\"math\"\n\t\"net/http\"\n\t\"net/http/"
  },
  {
    "path": "cmd/templ/generatecmd/proxy/proxy_test.go",
    "chars": 25813,
    "preview": "package proxy\n\nimport (\n\t\"bufio\"\n\t\"bytes\"\n\t\"compress/gzip\"\n\t\"context\"\n\t\"fmt\"\n\t\"io\"\n\t\"log/slog\"\n\t\"net/http\"\n\t\"net/http/ht"
  },
  {
    "path": "cmd/templ/generatecmd/proxy/script.js",
    "chars": 350,
    "preview": "(function() {\n  let templ_reloadSrc = window.templ_reloadSrc || new EventSource(\"/_templ/reload/events\");\n  templ_reload"
  },
  {
    "path": "cmd/templ/generatecmd/run/run_test.go",
    "chars": 2470,
    "preview": "package run_test\n\nimport (\n\t\"context\"\n\t\"embed\"\n\t\"io\"\n\t\"net/http\"\n\t\"os\"\n\t\"path/filepath\"\n\t\"syscall\"\n\t\"testing\"\n\t\"time\"\n\n\t"
  },
  {
    "path": "cmd/templ/generatecmd/run/run_unix.go",
    "chars": 1830,
    "preview": "//go:build unix\n\npackage run\n\nimport (\n\t\"context\"\n\t\"errors\"\n\t\"fmt\"\n\t\"os\"\n\t\"os/exec\"\n\t\"strings\"\n\t\"sync\"\n\t\"syscall\"\n\t\"time"
  },
  {
    "path": "cmd/templ/generatecmd/run/run_windows.go",
    "chars": 1425,
    "preview": "//go:build windows\n\npackage run\n\nimport (\n\t\"context\"\n\t\"os\"\n\t\"os/exec\"\n\t\"strconv\"\n\t\"strings\"\n\t\"sync\"\n)\n\nvar (\n\tm       = "
  },
  {
    "path": "cmd/templ/generatecmd/run/testprogram/go.mod.embed",
    "chars": 28,
    "preview": "module testprogram\n\ngo 1.23\n"
  },
  {
    "path": "cmd/templ/generatecmd/run/testprogram/main.go",
    "chars": 1800,
    "preview": "package main\n\nimport (\n\t\"flag\"\n\t\"fmt\"\n\t\"net/http\"\n\t\"os\"\n\t\"os/signal\"\n\t\"syscall\"\n\t\"time\"\n)\n\n// This is a test program. It"
  },
  {
    "path": "cmd/templ/generatecmd/sse/server.go",
    "chars": 1678,
    "preview": "package sse\n\nimport (\n\t_ \"embed\"\n\t\"fmt\"\n\t\"net/http\"\n\t\"sync\"\n\t\"sync/atomic\"\n\t\"time\"\n)\n\nfunc New() *Handler {\n\treturn &Han"
  },
  {
    "path": "cmd/templ/generatecmd/symlink/symlink_test.go",
    "chars": 1506,
    "preview": "package symlink\n\nimport (\n\t\"context\"\n\t\"io\"\n\t\"os\"\n\t\"path\"\n\t\"testing\"\n\n\t\"github.com/a-h/templ/cmd/templ/generatecmd\"\n\t\"git"
  },
  {
    "path": "cmd/templ/generatecmd/test-eventhandler/eventhandler_test.go",
    "chars": 3368,
    "preview": "package testeventhandler\n\nimport (\n\t\"context\"\n\t\"errors\"\n\t\"fmt\"\n\t\"go/scanner\"\n\t\"go/token\"\n\t\"io\"\n\t\"log/slog\"\n\t\"os\"\n\t\"testi"
  },
  {
    "path": "cmd/templ/generatecmd/test-eventhandler/multiple_errors.templ.error",
    "chars": 127,
    "preview": "package testeventhandler\n\nfunc invalid(a: string) string {\n    return \"foo\"\n}\n\ntempl multipleError(a: string) {\n    <div"
  },
  {
    "path": "cmd/templ/generatecmd/test-eventhandler/single_error.templ.error",
    "chars": 70,
    "preview": "package testeventhandler\n\ntempl singleError(a: string) {\n    <div/>\n}\n"
  },
  {
    "path": "cmd/templ/generatecmd/testwatch/generate_test.go",
    "chars": 12573,
    "preview": "package testwatch\n\nimport (\n\t\"bufio\"\n\t\"bytes\"\n\t\"context\"\n\t\"embed\"\n\t\"errors\"\n\t\"fmt\"\n\t\"io\"\n\t\"net\"\n\t\"net/http\"\n\t\"os\"\n\t\"path"
  },
  {
    "path": "cmd/templ/generatecmd/testwatch/testdata/go.mod.embed",
    "chars": 133,
    "preview": "module templ/testproject\n\ngo 1.25.0\n\nrequire github.com/a-h/templ v0.3.847 // indirect\n\nreplace github.com/a-h/templ => "
  },
  {
    "path": "cmd/templ/generatecmd/testwatch/testdata/go.sum",
    "chars": 330,
    "preview": "github.com/a-h/templ v0.3.833 h1:L/KOk/0VvVTBegtE0fp2RJQiBm7/52Zxv5fqlEHiQUU=\ngithub.com/a-h/templ v0.3.833/go.mod h1:cA"
  },
  {
    "path": "cmd/templ/generatecmd/testwatch/testdata/main.go",
    "chars": 1642,
    "preview": "package main\n\nimport (\n\t\"bytes\"\n\t\"compress/gzip\"\n\t\"flag\"\n\t\"fmt\"\n\t\"log/slog\"\n\t\"net/http\"\n\t\"os\"\n\t\"strconv\"\n\n\t\"github.com/a"
  },
  {
    "path": "cmd/templ/generatecmd/testwatch/testdata/templates.templ",
    "chars": 291,
    "preview": "package main\n\nimport \"fmt\"\n\ntempl Page(count int) {\n\t<!DOCTYPE html>\n\t<html>\n\t\t<head>\n\t\t\t<title>templ test page</title>\n"
  },
  {
    "path": "cmd/templ/generatecmd/testwatch/testdata/templates_templ.go",
    "chars": 2116,
    "preview": "// Code generated by templ - DO NOT EDIT.\n\npackage main\n\n//lint:file-ignore SA4006 This context is only used if a nested"
  },
  {
    "path": "cmd/templ/generatecmd/watcher/watch.go",
    "chars": 3480,
    "preview": "package watcher\n\nimport (\n\t\"context\"\n\t\"io/fs\"\n\t\"os\"\n\t\"path/filepath\"\n\t\"regexp\"\n\t\"sync\"\n\t\"time\"\n\n\t\"github.com/a-h/templ/i"
  },
  {
    "path": "cmd/templ/generatecmd/watcher/watch_test.go",
    "chars": 5197,
    "preview": "package watcher\n\nimport (\n\t\"context\"\n\t\"fmt\"\n\t\"regexp\"\n\t\"testing\"\n\t\"time\"\n\n\t\"github.com/fsnotify/fsnotify\"\n)\n\nfunc TestWa"
  },
  {
    "path": "cmd/templ/infocmd/main.go",
    "chars": 4437,
    "preview": "package infocmd\n\nimport (\n\t\"context\"\n\t\"encoding/json\"\n\t\"errors\"\n\t\"fmt\"\n\t\"io\"\n\t\"log/slog\"\n\t\"os\"\n\t\"os/exec\"\n\t\"runtime\"\n\t\"s"
  },
  {
    "path": "cmd/templ/lspcmd/httpdebug/handler.go",
    "chars": 3168,
    "preview": "package httpdebug\n\nimport (\n\t\"encoding/json\"\n\t\"io\"\n\t\"log/slog\"\n\t\"net/http\"\n\t\"net/url\"\n\n\t\"github.com/a-h/templ\"\n\t\"github."
  },
  {
    "path": "cmd/templ/lspcmd/httpdebug/list.templ",
    "chars": 434,
    "preview": "package httpdebug\n\ntempl list(uris []string) {\n\t<table>\n\t\t<tr>\n\t\t\t<th>File</th>\n\t\t\t<th></th>\n\t\t\t<th></th>\n\t\t\t<th></th>\n\t"
  },
  {
    "path": "cmd/templ/lspcmd/httpdebug/list_templ.go",
    "chars": 4840,
    "preview": "// Code generated by templ - DO NOT EDIT.\n\npackage httpdebug\n\n//lint:file-ignore SA4006 This context is only used if a n"
  },
  {
    "path": "cmd/templ/lspcmd/lsp_test.go",
    "chars": 28780,
    "preview": "package lspcmd\n\nimport (\n\t\"bytes\"\n\t\"context\"\n\t\"fmt\"\n\t\"io\"\n\t\"log/slog\"\n\t\"os\"\n\t\"strings\"\n\t\"sync\"\n\t\"testing\"\n\t\"time\"\n\t\"unic"
  },
  {
    "path": "cmd/templ/lspcmd/lspdiff/lspdiff.go",
    "chars": 828,
    "preview": "package lspdiff\n\nimport (\n\t\"github.com/a-h/templ/lsp/protocol\"\n\t\"github.com/google/go-cmp/cmp\"\n\t\"github.com/google/go-cm"
  },
  {
    "path": "cmd/templ/lspcmd/main.go",
    "chars": 3973,
    "preview": "package lspcmd\n\nimport (\n\t\"context\"\n\t\"fmt\"\n\t\"io\"\n\t\"log/slog\"\n\t\"net/http\"\n\t\"os\"\n\t\"os/signal\"\n\n\t\"github.com/a-h/templ/cmd/"
  },
  {
    "path": "cmd/templ/lspcmd/pls/main.go",
    "chars": 3051,
    "preview": "package pls\n\nimport (\n\t\"context\"\n\t\"errors\"\n\t\"fmt\"\n\t\"io\"\n\t\"log/slog\"\n\t\"os\"\n\t\"os/exec\"\n\t\"path\"\n\t\"runtime\"\n)\n\n// Options fo"
  },
  {
    "path": "cmd/templ/lspcmd/proxy/client.go",
    "chars": 5504,
    "preview": "package proxy\n\nimport (\n\t\"context\"\n\t\"fmt\"\n\t\"log/slog\"\n\t\"strings\"\n\n\tlsp \"github.com/a-h/templ/lsp/protocol\"\n)\n\n// Client "
  },
  {
    "path": "cmd/templ/lspcmd/proxy/diagnosticcache.go",
    "chars": 1575,
    "preview": "package proxy\n\nimport (\n\t\"sync\"\n\n\tlsp \"github.com/a-h/templ/lsp/protocol\"\n)\n\nfunc NewDiagnosticCache() *DiagnosticCache "
  },
  {
    "path": "cmd/templ/lspcmd/proxy/documentcontents.go",
    "chars": 5252,
    "preview": "package proxy\n\nimport (\n\t\"fmt\"\n\t\"log/slog\"\n\t\"strings\"\n\t\"sync\"\n\n\tlsp \"github.com/a-h/templ/lsp/protocol\"\n)\n\n// newDocumen"
  },
  {
    "path": "cmd/templ/lspcmd/proxy/documentcontents_test.go",
    "chars": 12399,
    "preview": "package proxy\n\nimport (\n\t\"log/slog\"\n\t\"os\"\n\t\"testing\"\n\n\tlsp \"github.com/a-h/templ/lsp/protocol\"\n\t\"github.com/google/go-cm"
  },
  {
    "path": "cmd/templ/lspcmd/proxy/import_test.go",
    "chars": 4356,
    "preview": "package proxy\n\nimport (\n\t\"fmt\"\n\t\"strings\"\n\t\"testing\"\n\n\t\"github.com/google/go-cmp/cmp\"\n)\n\nfunc TestFindLastImport(t *test"
  },
  {
    "path": "cmd/templ/lspcmd/proxy/rewrite.go",
    "chars": 686,
    "preview": "package proxy\n\nimport (\n\t\"path\"\n\t\"strings\"\n\n\tlsp \"github.com/a-h/templ/lsp/protocol\"\n)\n\nfunc convertTemplToGoURI(templUR"
  },
  {
    "path": "cmd/templ/lspcmd/proxy/server.go",
    "chars": 50153,
    "preview": "package proxy\n\nimport (\n\t\"context\"\n\t\"fmt\"\n\t\"log/slog\"\n\t\"os\"\n\t\"path/filepath\"\n\t\"regexp\"\n\t\"strings\"\n\n\t\"github.com/a-h/pars"
  },
  {
    "path": "cmd/templ/lspcmd/proxy/snippets.go",
    "chars": 3058,
    "preview": "package proxy\n\nimport lsp \"github.com/a-h/templ/lsp/protocol\"\n\nvar htmlSnippets = []lsp.CompletionItem{\n\t{\n\t\tLabel: \"<?>"
  },
  {
    "path": "cmd/templ/lspcmd/proxy/sourcemapcache.go",
    "chars": 1188,
    "preview": "package proxy\n\nimport (\n\t\"slices\"\n\t\"sync\"\n\n\t\"github.com/a-h/templ/parser/v2\"\n)\n\n// NewSourceMapCache creates a cache of "
  },
  {
    "path": "cmd/templ/lspcmd/proxy/sourcemapcache_test.go",
    "chars": 1449,
    "preview": "package proxy\n\nimport (\n\t\"testing\"\n\n\t\"github.com/a-h/templ/parser/v2\"\n\t\"github.com/google/go-cmp/cmp\"\n)\n\nfunc TestSource"
  },
  {
    "path": "cmd/templ/lspcmd/stdrwc.go",
    "chars": 1103,
    "preview": "package lspcmd\n\nimport (\n\t\"errors\"\n\t\"io\"\n\t\"log/slog\"\n)\n\n// stdrwc (standard read/write closer) reads from stdin, and wri"
  },
  {
    "path": "cmd/templ/main.go",
    "chars": 7677,
    "preview": "package main\n\nimport (\n\t\"context\"\n\t\"flag\"\n\t\"fmt\"\n\t\"io\"\n\t\"os\"\n\t\"os/signal\"\n\t\"runtime\"\n\t\"syscall\"\n\n\t\"github.com/a-h/templ\""
  },
  {
    "path": "cmd/templ/main_test.go",
    "chars": 2429,
    "preview": "package main\n\nimport (\n\t\"bytes\"\n\t\"strings\"\n\t\"testing\"\n\n\t\"github.com/a-h/templ\"\n\t\"github.com/google/go-cmp/cmp\"\n)\n\nfunc T"
  },
  {
    "path": "cmd/templ/processor/processor.go",
    "chars": 1527,
    "preview": "package processor\n\nimport (\n\t\"io/fs\"\n\t\"path/filepath\"\n\t\"strings\"\n\t\"sync\"\n\t\"time\"\n\n\t\"github.com/a-h/templ/internal/skipdi"
  },
  {
    "path": "cmd/templ/processor/processor_test.go",
    "chars": 416,
    "preview": "package processor\n\nimport (\n\t\"os\"\n\t\"testing\"\n)\n\nfunc TestFindTemplates(t *testing.T) {\n\tt.Run(\"returns an error if the d"
  },
  {
    "path": "cmd/templ/sloghandler/handler.go",
    "chars": 2678,
    "preview": "package sloghandler\n\nimport (\n\t\"context\"\n\t\"io\"\n\t\"log/slog\"\n\t\"strings\"\n\t\"sync\"\n\n\t\"github.com/fatih/color\"\n)\n\nfunc NewLogg"
  },
  {
    "path": "cmd/templ/testproject/testdata/css-classes/classes.go",
    "chars": 44,
    "preview": "package cssclasses\n\nconst Header = \"header\"\n"
  },
  {
    "path": "cmd/templ/testproject/testdata/go.mod.embed",
    "chars": 133,
    "preview": "module templ/testproject\n\ngo 1.25.0\n\nrequire github.com/a-h/templ v0.3.847 // indirect\n\nreplace github.com/a-h/templ => "
  },
  {
    "path": "cmd/templ/testproject/testdata/go.sum",
    "chars": 330,
    "preview": "github.com/a-h/templ v0.3.833 h1:L/KOk/0VvVTBegtE0fp2RJQiBm7/52Zxv5fqlEHiQUU=\ngithub.com/a-h/templ v0.3.833/go.mod h1:cA"
  },
  {
    "path": "cmd/templ/testproject/testdata/main.go",
    "chars": 553,
    "preview": "package main\n\nimport (\n\t\"flag\"\n\t\"fmt\"\n\t\"net/http\"\n\t\"os\"\n\n\t\"github.com/a-h/templ\"\n)\n\nvar flagPort = flag.Int(\"port\", 0, \""
  },
  {
    "path": "cmd/templ/testproject/testdata/remotechild.templ",
    "chars": 64,
    "preview": "package main\n\ntempl Remote() {\n\t<p>This is remote content</p>\n}\n"
  },
  {
    "path": "cmd/templ/testproject/testdata/remotechild_templ.go",
    "chars": 1337,
    "preview": "// Code generated by templ - DO NOT EDIT.\n\npackage main\n\n//lint:file-ignore SA4006 This context is only used if a nested"
  },
  {
    "path": "cmd/templ/testproject/testdata/remoteparent.templ",
    "chars": 85,
    "preview": "package main\n\ntempl RemoteInclusionTest() {\n\t@Remote\n}\n\ntempl Remote2() {\n\t@Remote\n}\n"
  },
  {
    "path": "cmd/templ/testproject/testdata/remoteparent_templ.go",
    "chars": 2339,
    "preview": "// Code generated by templ - DO NOT EDIT.\n\npackage main\n\n//lint:file-ignore SA4006 This context is only used if a nested"
  },
  {
    "path": "cmd/templ/testproject/testdata/templates.templ",
    "chars": 362,
    "preview": "package main\n\nimport \"fmt\"\n\ntempl Page(count int) {\n\t<!DOCTYPE html>\n\t<html>\n\t\t<head>\n\t\t\t<title>templ test page</title>\n"
  },
  {
    "path": "cmd/templ/testproject/testdata/templates_templ.go",
    "chars": 2177,
    "preview": "// Code generated by templ - DO NOT EDIT.\n\npackage main\n\n//lint:file-ignore SA4006 This context is only used if a nested"
  },
  {
    "path": "cmd/templ/testproject/testproject.go",
    "chars": 1879,
    "preview": "package testproject\n\nimport (\n\t\"bytes\"\n\t\"embed\"\n\t\"fmt\"\n\t\"os\"\n\t\"path/filepath\"\n\t\"strings\"\n)\n\n//go:embed testdata/*\nvar te"
  },
  {
    "path": "cmd/templ/visualize/sourcemapvisualisation.templ",
    "chars": 1694,
    "preview": "package visualize\n\ncss row() {\n\tdisplay: flex;\n}\n\ncss column() {\n\tflex: 50%;\n\toverflow-y: scroll;\n\tmax-height: 100vh;\n}\n"
  },
  {
    "path": "cmd/templ/visualize/sourcemapvisualisation_templ.go",
    "chars": 12653,
    "preview": "// Code generated by templ - DO NOT EDIT.\n\npackage visualize\n\n//lint:file-ignore SA4006 This context is only used if a n"
  },
  {
    "path": "cmd/templ/visualize/types.go",
    "chars": 2498,
    "preview": "package visualize\n\nimport (\n\t\"context\"\n\t\"fmt\"\n\t\"html\"\n\t\"io\"\n\t\"strconv\"\n\t\"strings\"\n\n\t\"github.com/a-h/templ\"\n\t\"github.com/"
  },
  {
    "path": "cosign.pub",
    "chars": 178,
    "preview": "-----BEGIN PUBLIC KEY-----\nMFkwEwYHKoZIzj0CAQYIKoZIzj0DAQcDQgAEqHp75uAj8XqKrLO2YvY0M2EddckH\nevQnNAj+0GmBptqdf3NJcUCjL6w4"
  },
  {
    "path": "docs/.gitignore",
    "chars": 250,
    "preview": "# Dependencies\n/node_modules\n\n# Production\n/build\n\n# Generated files\n.docusaurus\n.cache-loader\n\n# Misc\n.DS_Store\n.env.lo"
  },
  {
    "path": "docs/README.md",
    "chars": 770,
    "preview": "# Website\n\nThis website is built using [Docusaurus 2](https://docusaurus.io/), a modern static website generator.\n\n### I"
  },
  {
    "path": "docs/babel.config.js",
    "chars": 89,
    "preview": "module.exports = {\n  presets: [require.resolve('@docusaurus/core/lib/babel/preset')],\n};\n"
  },
  {
    "path": "docs/docs/02-quick-start/01-installation.md",
    "chars": 4060,
    "preview": "# Installation\n\n## go install (global)\n\nWith Go 1.24 or greater installed, run:\n\n```bash\ngo install github.com/a-h/templ"
  },
  {
    "path": "docs/docs/02-quick-start/02-creating-a-simple-templ-component.md",
    "chars": 1812,
    "preview": "# Creating a simple templ component\n\nTo create a templ component, first create a new Go project.\n\n## Setup project\n\nCrea"
  },
  {
    "path": "docs/docs/02-quick-start/03-running-your-first-templ-application.md",
    "chars": 879,
    "preview": "# Running your first templ application\n\nLet's update the previous application to serve HTML over HTTP instead of writing"
  },
  {
    "path": "docs/docs/02-quick-start/_category_.json",
    "chars": 46,
    "preview": "{\n  \"position\": 2,\n  \"label\": \"Quick start\"\n}\n"
  },
  {
    "path": "docs/docs/03-syntax-and-usage/01-basic-syntax.md",
    "chars": 1100,
    "preview": "# Basic syntax\n\n## Package name and imports\n\ntempl files start with a package name, followed by any required imports, ju"
  },
  {
    "path": "docs/docs/03-syntax-and-usage/02-elements.md",
    "chars": 1532,
    "preview": "# Elements\n\ntempl elements are used to render HTML within templ components.\n\n```templ title=\"button.templ\"\npackage main\n"
  },
  {
    "path": "docs/docs/03-syntax-and-usage/03-attributes.md",
    "chars": 7908,
    "preview": "# Attributes\n\n## Constant attributes\n\ntempl elements can have HTML attributes that use the double quote character `\"`.\n\n"
  },
  {
    "path": "docs/docs/03-syntax-and-usage/04-expressions.md",
    "chars": 2395,
    "preview": "# Expressions\n\n## Interpolation expressions\n\nWithin a templ element, expressions can be used to interpolate Go values. C"
  },
  {
    "path": "docs/docs/03-syntax-and-usage/05-statements.md",
    "chars": 2563,
    "preview": "# Statements\n\n## Control flow\n\nWithin a templ element, a subset of Go statements can be used directly.\n\nThese Go stateme"
  },
  {
    "path": "docs/docs/03-syntax-and-usage/06-if-else.md",
    "chars": 507,
    "preview": "# If/else\n\ntempl uses standard Go `if`/`else` statements which can be used to conditionally render components and elemen"
  },
  {
    "path": "docs/docs/03-syntax-and-usage/07-switch.md",
    "chars": 588,
    "preview": "# Switch\n\ntempl uses standard Go `switch` statements which can be used to conditionally render components and elements.\n"
  },
  {
    "path": "docs/docs/03-syntax-and-usage/08-loops.md",
    "chars": 299,
    "preview": "# For loops\n\nUse the standard Go `for` loop for iteration.\n\n```templ title=\"component.templ\"\npackage main\n\ntempl nameLis"
  },
  {
    "path": "docs/docs/03-syntax-and-usage/09-raw-go.md",
    "chars": 460,
    "preview": "# Raw Go\n\nFor some more advanced use cases it may be useful to write Go code statements in your template.\n\nUse the `{{ ."
  },
  {
    "path": "docs/docs/03-syntax-and-usage/10-template-composition.md",
    "chars": 5768,
    "preview": "# Template composition\n\nTemplates can be composed using the import expression.\n\n```templ\ntempl showAll() {\n\t@left()\n\t@mi"
  },
  {
    "path": "docs/docs/03-syntax-and-usage/11-forms.md",
    "chars": 21119,
    "preview": "# Forms and validation\n\nTo pass data from the client to the server without using JavaScript, you can use HTML forms to P"
  },
  {
    "path": "docs/docs/03-syntax-and-usage/12-css-style-management.md",
    "chars": 12236,
    "preview": "# CSS style management\n\n## HTML class and style attributes\n\nThe standard HTML `class` and `style` attributes can be adde"
  },
  {
    "path": "docs/docs/03-syntax-and-usage/13-script-templates.md",
    "chars": 16055,
    "preview": "# Using JavaScript with templ\n\n## Script tags\n\nUse standard `<script>` tags, and standard HTML attributes to run JavaScr"
  },
  {
    "path": "docs/docs/03-syntax-and-usage/14-comments.md",
    "chars": 589,
    "preview": "# Comments\n\n# HTML comments\n\nInside templ statements, use HTML comments.\n\n```templ title=\"template.templ\"\ntempl template"
  },
  {
    "path": "docs/docs/03-syntax-and-usage/15-context.md",
    "chars": 5112,
    "preview": "# Context\n\n## What problems does `context` solve?\n\n### \"Prop drilling\"\n\nIt can be cumbersome to pass data from parents t"
  },
  {
    "path": "docs/docs/03-syntax-and-usage/16-using-with-go-templates.md",
    "chars": 1805,
    "preview": "# Using with `html/template`\n\nTempl components can be used with the Go standard library [`html/template`](https://pkg.go"
  },
  {
    "path": "docs/docs/03-syntax-and-usage/17-rendering-raw-html.md",
    "chars": 591,
    "preview": "# Rendering raw HTML\n\nTo render HTML that has come from a trusted source, bypassing all HTML escaping and security mecha"
  },
  {
    "path": "docs/docs/03-syntax-and-usage/18-render-once.md",
    "chars": 3067,
    "preview": "# Render once\n\nIf you need to render something to the page once per page, you can create a `*OnceHandler` with `templ.Ne"
  },
  {
    "path": "docs/docs/03-syntax-and-usage/19-fragments.md",
    "chars": 4586,
    "preview": "# Fragments\n\nThe `templ.Fragment` component can be used to render a subsection of a template, discarding all other outpu"
  },
  {
    "path": "docs/docs/03-syntax-and-usage/20-using-react-with-templ.md",
    "chars": 8712,
    "preview": "# Using React with templ\n\ntempl is great for server-side rendering. Combined with [htmx](https://htmx.org/), it's even m"
  },
  {
    "path": "docs/docs/03-syntax-and-usage/_category_.json",
    "chars": 51,
    "preview": "{\n  \"position\": 3,\n  \"label\": \"Syntax and usage\"\n}\n"
  },
  {
    "path": "docs/docs/04-core-concepts/01-components.md",
    "chars": 2994,
    "preview": "# Components\n\ntempl Components are markup and code that is compiled into functions that return a `templ.Component` inter"
  },
  {
    "path": "docs/docs/04-core-concepts/02-template-generation.md",
    "chars": 2972,
    "preview": "# Template generation\n\nTo generate Go code from `*.templ` files, use the `templ` command line tool.\n\n```\ntempl generate\n"
  },
  {
    "path": "docs/docs/04-core-concepts/03-testing.md",
    "chars": 9291,
    "preview": "# Testing\n\nTo test that data is rendered as expected, there are two main ways to do it:\n\n* Expectation testing - testing"
  },
  {
    "path": "docs/docs/04-core-concepts/04-view-models.md",
    "chars": 1867,
    "preview": "# View models\n\nWith templ, you can pass any Go type into your template as parameters, and you can call arbitrary functio"
  },
  {
    "path": "docs/docs/04-core-concepts/_category_.json",
    "chars": 48,
    "preview": "{\n  \"position\": 4,\n  \"label\": \"Core concepts\"\n}\n"
  },
  {
    "path": "docs/docs/05-server-side-rendering/01-creating-an-http-server-with-templ.md",
    "chars": 3167,
    "preview": "# Creating an HTTP server with templ\n\n### Static pages\n\nTo use a templ component as a HTTP handler, the `templ.Handler` "
  },
  {
    "path": "docs/docs/05-server-side-rendering/02-example-counter-application.md",
    "chars": 5777,
    "preview": "# Example: Counter application\n\nWeb applications typically need to store application state, some of which is per-user, a"
  },
  {
    "path": "docs/docs/05-server-side-rendering/03-htmx.md",
    "chars": 3405,
    "preview": "# htmx\n\n[htmx](https://htmx.org) can be used to selectively replace content within a web page, instead of replacing the "
  },
  {
    "path": "docs/docs/05-server-side-rendering/04-datastar.md",
    "chars": 6589,
    "preview": "# Datastar\n\n[Datastar](https://data-star.dev) is a hypermedia framework for building reactive web apps. With reactive si"
  },
  {
    "path": "docs/docs/05-server-side-rendering/05-streaming.md",
    "chars": 4946,
    "preview": "# HTTP Streaming\n\nThe default behaviour of the `templ.Handler` is to render the template to a buffer and then write the "
  },
  {
    "path": "docs/docs/05-server-side-rendering/_category_.json",
    "chars": 56,
    "preview": "{\n  \"position\": 5,\n  \"label\": \"Server-side rendering\"\n}\n"
  },
  {
    "path": "docs/docs/06-static-rendering/01-generating-static-html-files-with-templ.md",
    "chars": 2217,
    "preview": "# Generating static HTML files with templ\n\ntempl components implement the `templ.Component` interface.\n\nThe interface ha"
  },
  {
    "path": "docs/docs/06-static-rendering/02-blog-example.md",
    "chars": 6064,
    "preview": "# Blog example\n\nThis example demonstrates building a static blog with templ.\n\n## Create a blog template\n\nCreate a templa"
  },
  {
    "path": "docs/docs/06-static-rendering/03-deploying-static-files.md",
    "chars": 1257,
    "preview": "# Deploying static files\n\nOnce you have built static HTML files with templ, you can serve them on any static site hostin"
  },
  {
    "path": "docs/docs/06-static-rendering/_category_.json",
    "chars": 51,
    "preview": "{\n  \"position\": 6,\n  \"label\": \"Static rendering\"\n}\n"
  },
  {
    "path": "docs/docs/07-project-structure/01-project-structure.md",
    "chars": 8181,
    "preview": "# Project structure\n\nThe example counter project demonstrates a way to structure your applications.\n\nhttps://github.com/"
  },
  {
    "path": "docs/docs/07-project-structure/_category_.json",
    "chars": 52,
    "preview": "{\n  \"position\": 7,\n  \"label\": \"Project structure\"\n}\n"
  },
  {
    "path": "docs/docs/08-hosting-and-deployment/01-hosting-on-aws-lambda.md",
    "chars": 3371,
    "preview": "# Hosting on AWS Lambda\n\nAWS Lambda is a great way to host templ applications.\n\nThe example at https://github.com/a-h/te"
  },
  {
    "path": "docs/docs/08-hosting-and-deployment/02-hosting-using-docker.md",
    "chars": 3084,
    "preview": "# Hosting using Docker\n\nApplications that use templ can be deployed using the same techniques and platforms as any other"
  },
  {
    "path": "docs/docs/08-hosting-and-deployment/_category_.json",
    "chars": 57,
    "preview": "{\n  \"position\": 8,\n  \"label\": \"Hosting and deployment\"\n}\n"
  },
  {
    "path": "docs/docs/09-developer-tools/01-cli.md",
    "chars": 4213,
    "preview": "# CLI\n\n`templ` provides a command line interface. Most users will only need to run the `templ generate` command to gener"
  },
  {
    "path": "docs/docs/09-developer-tools/02-ide-support.md",
    "chars": 18364,
    "preview": "# IDE support\n\n## Visual Studio Code\n\nThere's a VS Code extension, just make sure you've already installed templ and tha"
  },
  {
    "path": "docs/docs/09-developer-tools/03-live-reload.md",
    "chars": 6874,
    "preview": "# Live reload\n\nTo enable live reload on a `templ` app use:\n\n```bash\ntempl generate --watch --proxy=\"http://localhost:808"
  },
  {
    "path": "docs/docs/09-developer-tools/04-live-reload-with-other-tools.md",
    "chars": 8035,
    "preview": "# Live reload with other tools\n\nBrowser live reload allows you to see your changes immediately without having to switch "
  },
  {
    "path": "docs/docs/09-developer-tools/05-llm.md",
    "chars": 569,
    "preview": "# Coding assistants / LLMs\n\nTo provide AI coding assistants such as GitHub Copilot, Cursor or similar with help on how t"
  },
  {
    "path": "docs/docs/09-developer-tools/06-cicd.md",
    "chars": 745,
    "preview": "# Ensuring templ files have been committed\n\nIt's common practice to commit generated `*_templ.go` files to your source c"
  },
  {
    "path": "docs/docs/09-developer-tools/_category_.json",
    "chars": 50,
    "preview": "{\n  \"position\": 9,\n  \"label\": \"Developer tools\"\n}\n"
  },
  {
    "path": "docs/docs/10-security/01-injection-attacks.md",
    "chars": 2342,
    "preview": "# Injection attacks\n\ntempl is designed to prevent user-provided data from being used to inject vulnerabilities.\n\n`<scrip"
  },
  {
    "path": "docs/docs/10-security/02-content-security-policy.md",
    "chars": 2087,
    "preview": "# Content security policy\n\n## Nonces\n\nIn templ [script templates](/syntax-and-usage/script-templates#script-templates) a"
  },
  {
    "path": "docs/docs/10-security/03-code-signing.md",
    "chars": 350,
    "preview": "# Code signing\n\nBinaries are created by the GitHub Actions workflow at https://github.com/a-h/templ/blob/main/.github/wo"
  },
  {
    "path": "docs/docs/10-security/_category_.json",
    "chars": 44,
    "preview": "{\n  \"position\": 10,\n  \"label\": \"Security\"\n}\n"
  },
  {
    "path": "docs/docs/11-media/_category_.json",
    "chars": 51,
    "preview": "{\n  \"position\": 11,\n  \"label\": \"Media and talks\"\n}\n"
  },
  {
    "path": "docs/docs/11-media/index.md",
    "chars": 2257,
    "preview": "# Media and talks\n\n# Go Podcast 2024\n\nhttps://gopodcast.dev/episodes/adrian-hesketh-and-joe-davidson-on-templ\n\n# Gopherc"
  },
  {
    "path": "docs/docs/12-integrations/01-web-frameworks.md",
    "chars": 2280,
    "preview": "# Web frameworks\n\nTempl is framework agnostic but that does not mean it can not be used with Go frameworks and other too"
  },
  {
    "path": "docs/docs/12-integrations/02-internationalization.md",
    "chars": 2438,
    "preview": "# Internationalization\n\ntempl can be used with 3rd party internationalization libraries.\n\n## ctxi18n\n\nhttps://github.com"
  },
  {
    "path": "docs/docs/12-integrations/_category_.json",
    "chars": 48,
    "preview": "{\n  \"position\": 12,\n  \"label\": \"Integrations\"\n}\n"
  },
  {
    "path": "docs/docs/13-experimental/01-overview.md",
    "chars": 562,
    "preview": "# Experimental packages\n\nExperimental Packages for templ are available at https://github.com/templ-go/x/\n\n:::warning\n- P"
  },
  {
    "path": "docs/docs/13-experimental/02-urlbuilder.md",
    "chars": 648,
    "preview": "# urlbuilder\n\nA simple URL builder to construct a `templ.SafeURL`.\n\n```templ title=\"component.templ\"\nimport (\n  \"github."
  },
  {
    "path": "docs/docs/13-experimental/_category_.json",
    "chars": 48,
    "preview": "{\n  \"position\": 13,\n  \"label\": \"Experimental\"\n}\n"
  },
  {
    "path": "docs/docs/14-help-and-community/_category_.json",
    "chars": 54,
    "preview": "{\n  \"position\": 14,\n  \"label\": \"Help and community\"\n}\n"
  },
  {
    "path": "docs/docs/14-help-and-community/index.md",
    "chars": 263,
    "preview": "# Getting help\n\nFor help from the community, talking about new ideas, and general discussion:\n\n## Slack\n\nUse the #templ "
  },
  {
    "path": "docs/docs/15-component-libraries/_category_.json",
    "chars": 55,
    "preview": "{\n  \"position\": 15,\n  \"label\": \"Component Libraries\"\n}\n"
  },
  {
    "path": "docs/docs/15-component-libraries/index.md",
    "chars": 1149,
    "preview": "# Component Libraries\n\nComponent libraries in the templ ecosystem provide ready-to-use UI elements.\n\n## templUI\n\n![templ"
  },
  {
    "path": "docs/docs/16-faq/_category_.json",
    "chars": 39,
    "preview": "{\n  \"position\": 16,\n  \"label\": \"FAQ\"\n}\n"
  },
  {
    "path": "docs/docs/16-faq/index.md",
    "chars": 353,
    "preview": "# FAQ\n\n## How can I migrate from templ version 0.1.x to templ 0.2.x syntax?\n\nVersions of templ &lt;= v0.2.663 include a "
  },
  {
    "path": "docs/docs/go.mod",
    "chars": 142,
    "preview": "module github.com/a-h/templ/docs\n\ngo 1.20\n\nrequire github.com/gosimple/slug v1.13.1\n\nrequire github.com/gosimple/unideco"
  },
  {
    "path": "docs/docs/go.sum",
    "chars": 346,
    "preview": "github.com/gosimple/slug v1.13.1 h1:bQ+kpX9Qa6tHRaK+fZR0A0M2Kd7Pa5eHPPsb1JpHD+Q=\ngithub.com/gosimple/slug v1.13.1/go.mod"
  },
  {
    "path": "docs/docs/index.md",
    "chars": 824,
    "preview": "---\nsidebar_position: 1\n---\n\n# Introduction\n\n## templ - build HTML with Go\n\nCreate components that render fragments of H"
  },
  {
    "path": "docs/docs/main.go",
    "chars": 3634,
    "preview": "package main\n\nimport (\n\t\"encoding/json\"\n\t\"fmt\"\n\t\"os\"\n\t\"strings\"\n\n\t\"github.com/gosimple/slug\"\n)\n\ntype Section struct {\n\tN"
  },
  {
    "path": "docs/docusaurus.config.js",
    "chars": 2892,
    "preview": "// @ts-check\n// Note: type annotations allow type checking and IDEs autocompletion\n\nconst lightCodeTheme = require('pris"
  },
  {
    "path": "docs/package.json",
    "chars": 1329,
    "preview": "{\n  \"name\": \"docs\",\n  \"version\": \"0.0.0\",\n  \"private\": true,\n  \"scripts\": {\n    \"docusaurus\": \"docusaurus\",\n    \"start\":"
  },
  {
    "path": "docs/sidebars.js",
    "chars": 781,
    "preview": "/**\n * Creating a sidebar enables you to:\n - create an ordered group of docs\n - render a sidebar for each doc of that gr"
  },
  {
    "path": "docs/src/css/custom.css",
    "chars": 1144,
    "preview": "/**\n * Any CSS included here will be global. The classic template\n * bundles Infima by default. Infima is a CSS framewor"
  },
  {
    "path": "docs/src/theme/prism-include-languages.js",
    "chars": 7093,
    "preview": "import siteConfig from '@generated/docusaurus.config';\nexport default function prismIncludeLanguages(PrismObject) {\n    "
  },
  {
    "path": "docs/static/.nojekyll",
    "chars": 0,
    "preview": ""
  },
  {
    "path": "examples/blog/go.mod",
    "chars": 280,
    "preview": "module github.com/a-h/templ/examples/blog\n\ngo 1.25.0\n\nrequire (\n\tgithub.com/PuerkitoBio/goquery v1.10.1\n\tgithub.com/a-h/"
  },
  {
    "path": "examples/blog/go.sum",
    "chars": 6407,
    "preview": "github.com/PuerkitoBio/goquery v1.10.1 h1:Y8JGYUkXWTGRB6Ars3+j3kN0xg1YqqlwvdTV8WTFQcU=\ngithub.com/PuerkitoBio/goquery v1"
  },
  {
    "path": "examples/blog/main.go",
    "chars": 1200,
    "preview": "package main\n\nimport (\n\t\"fmt\"\n\t\"log\"\n\t\"net/http\"\n\n\t\"github.com/a-h/templ\"\n)\n\nfunc main() {\n\t// Use a template that doesn"
  },
  {
    "path": "examples/blog/posts.templ",
    "chars": 1125,
    "preview": "package main\n\nimport (\n\t\"fmt\"\n\t\"time\"\n)\n\ntempl headerTemplate(name string) {\n\t<header data-testid=\"headerTemplate\">\n\t\t<h"
  },
  {
    "path": "examples/blog/posts_templ.go",
    "chars": 14027,
    "preview": "// Code generated by templ - DO NOT EDIT.\n\npackage main\n\n//lint:file-ignore SA4006 This context is only used if a nested"
  },
  {
    "path": "examples/blog/posts_test.go",
    "chars": 6592,
    "preview": "package main\n\nimport (\n\t\"context\"\n\t\"errors\"\n\t\"fmt\"\n\t\"io\"\n\t\"log\"\n\t\"net/http\"\n\t\"net/http/httptest\"\n\t\"testing\"\n\t\"time\"\n\n\t\"g"
  },
  {
    "path": "examples/content-security-policy/main.go",
    "chars": 1670,
    "preview": "package main\n\nimport (\n\t\"crypto/rand\"\n\t\"fmt\"\n\t\"math/big\"\n\t\"net/http\"\n\t\"os\"\n\n\t\"log/slog\"\n\n\t\"github.com/a-h/templ\"\n)\n\nfunc"
  },
  {
    "path": "examples/content-security-policy/templates.templ",
    "chars": 87,
    "preview": "package main\n\nscript sayHello() {\n\talert(\"Hello\")\n}\n\ntempl template() {\n\t@sayHello()\n}\n"
  },
  {
    "path": "examples/content-security-policy/templates_templ.go",
    "chars": 1596,
    "preview": "// Code generated by templ - DO NOT EDIT.\n\npackage main\n\n//lint:file-ignore SA4006 This context is only used if a nested"
  },
  {
    "path": "examples/counter/Dockerfile",
    "chars": 93,
    "preview": "FROM pierrezemb/gostatic\nCOPY ./public/ /srv/http/\nENTRYPOINT [\"/goStatic\", \"-port\", \"8080\"]\n"
  },
  {
    "path": "examples/counter/README.md",
    "chars": 193,
    "preview": "## Tasks\n\n### generate\n\n```sh\ntempl generate\n```\n\n### deploy\n\nrequires: generate\ndir: cdk\n\n```sh\ncdk deploy\n```\n\n### dep"
  },
  {
    "path": "examples/counter/assets/css/bulma.css",
    "chars": 245486,
    "preview": "/*! bulma.io v0.9.4 | MIT License | github.com/jgthms/bulma */\n/* Bulma Utilities */\n.button, .input, .textarea, .select"
  },
  {
    "path": "examples/counter/assets/favicon/about.txt",
    "chars": 355,
    "preview": "This favicon was generated using the following font:\n\n- Font Title: Leckerli One\n- Font Author: Copyright (c) 2011 Gesin"
  },
  {
    "path": "examples/counter/assets/favicon/site.webmanifest",
    "chars": 294,
    "preview": "{\"name\":\"\",\"short_name\":\"\",\"icons\":[{\"src\":\"/assets/favicon/android-chrome-192x192.png\",\"sizes\":\"192x192\",\"type\":\"image/"
  },
  {
    "path": "examples/counter/cdk/.gitignore",
    "chars": 282,
    "preview": "# Binaries for programs and plugins\n*.exe\n*.exe~\n*.dll\n*.so\n*.dylib\n\n# Test binary, built with `go test -c`\n*.test\n\n# Ou"
  },
  {
    "path": "examples/counter/cdk/cdk.json",
    "chars": 1957,
    "preview": "{\n  \"app\": \"go mod download && go run stack.go\",\n  \"watch\": {\n    \"include\": [\n      \"**\"\n    ],\n    \"exclude\": [\n      "
  },
  {
    "path": "examples/counter/cdk/stack.go",
    "chars": 5456,
    "preview": "package main\n\nimport (\n\t\"fmt\"\n\n\t\"github.com/aws/aws-cdk-go/awscdk/v2\"\n\t\"github.com/aws/aws-cdk-go/awscdk/v2/awscloudfron"
  },
  {
    "path": "examples/counter/components/components.templ",
    "chars": 2052,
    "preview": "package components\n\nimport \"strconv\"\n\ncss border() {\n\tborder: 1px solid #eeeeee;\n\tborder-radius: 4px;\n\tmargin: 10px;\n\tpa"
  },
  {
    "path": "examples/counter/components/components_templ.go",
    "chars": 8083,
    "preview": "// Code generated by templ - DO NOT EDIT.\n\npackage components\n\n//lint:file-ignore SA4006 This context is only used if a "
  }
]

// ... and 633 more files (download for full content)

About this extraction

This page contains the full source code of the a-h/templ GitHub repository, extracted and formatted as plain text for AI agents and large language models (LLMs). The extraction includes 833 files (3.3 MB), approximately 908.5k tokens, and a symbol index with 3138 extracted functions, classes, methods, constants, and types. Use this with OpenClaw, Claude, ChatGPT, Cursor, Windsurf, or any other AI tool that accepts text input. You can copy the full output to your clipboard or download it as a .txt file.

Extracted by GitExtract — free GitHub repo to text converter for AI. Built by Nikandr Surkov.

Copied to clipboard!