You signed in with another tab or window. Reload to refresh your session.You signed out in another tab or window. Reload to refresh your session.You switched accounts on another tab or window. Reload to refresh your session.Dismiss alert
Copy file name to clipboardExpand all lines: .github/copilot-instructions.md
+24Lines changed: 24 additions & 0 deletions
Display the source diff
Display the rich diff
Original file line number
Diff line number
Diff line change
@@ -23,13 +23,16 @@ If you run `xc` you can get see a list of the development tasks that can be run,
23
23
The most useful tasks for local development are:
24
24
25
25
*`xc install-snapshot` - builds the templ CLI and installs it into `~/bin`. Ensure that this is in your path.
26
+
*`xc generate` - generates Go code from the templ files in the project.
26
27
*`xc test` - regenerates all templates, and runs the unit tests.
27
28
*`xc fmt` - runs `gofmt` to format all Go code.
28
29
*`xc lint` - run the same linting as run in the CI process.
29
30
*`xc docs-run` - run the Docusaurus documentation site.
30
31
31
32
templ has a code generation step, this is automatically carried out using `xc test`.
32
33
34
+
Don't install templ globally using `xc install-snapshot` or `go install`. Use the `xc generate` or `xc test` tasks to generate the code, which will also run the tests.
35
+
33
36
## Commit messages
34
37
35
38
The project using https://www.conventionalcommits.org/en/v1.0.0/
@@ -60,3 +63,24 @@ Examples:
60
63
* Use the `xc fmt` and `xc lint` build tasks to format and lint code before committing.
61
64
* Don't use unnecessary comments that explain what the code does.
62
65
* If comments are used, ensure that they are full sentences, and use proper punctuation, including ending with a full stop.
66
+
67
+
## Tests
68
+
69
+
* Tests for generated code are in the `./generator` directory. Each test is in a subdirectory.
70
+
* Tests for the templ CLI are in the `./cmd/templ` directory.
71
+
* Tests for the templ runtime are in the root directory.
72
+
* Tests for formatting templ files are in `./parser/v2/formattestdata` - it uses txtar to store tests.
73
+
* The `htmldiff` library does not take whitespace into account, so cannot be used to test output whitespace handling.
74
+
* 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.
75
+
76
+
## Moving and renaming files
77
+
78
+
* templ files have the `.templ` extension.
79
+
* If a `project.templ` file is created, after generation a `project_templ.go` file will be created.
80
+
* If a `project.templ` file is renamed, you must also rename the generated `project_templ.go` file.
81
+
* If a `project.templ` file is moved, you must also move the generated `project_templ.go` file.
82
+
* If a `project.templ` file is deleted, you must also delete the generated `project_templ.go` file.
83
+
84
+
# Files
85
+
86
+
* Don't attempt to create helper or utility tests in the `./tmp` or `/tmp` directory. Create unit tests in the relevant directory instead.
0 commit comments