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
+8-1Lines changed: 8 additions & 1 deletion
Display the source diff
Display the rich diff
Original file line number
Diff line number
Diff line change
@@ -1,5 +1,10 @@
1
1
# Coding standards
2
2
3
+
## Behaviour
4
+
5
+
* Always run `go fmt` after making changes to Go code.
6
+
* Always run unit tests after making changes to Go code.
7
+
3
8
## Environment setup
4
9
5
10
* Ensure that the user has direnv installed, and that it is set up correctly in their shell. See https://direnv.net/docs/installation.html
@@ -25,13 +30,14 @@ The most useful tasks for local development are:
25
30
*`xc install-snapshot` - builds the templ CLI and installs it into `~/bin`. Ensure that this is in your path.
26
31
*`xc generate` - generates Go code from the templ files in the project.
27
32
*`xc test` - regenerates all templates, and runs the unit tests.
33
+
*`xc test-short` - runs shorter tests, avoiding long running tests for filesystem watchers etc.
28
34
*`xc fmt` - runs `gofmt` to format all Go code.
29
35
*`xc lint` - run the same linting as run in the CI process.
30
36
*`xc docs-run` - run the Docusaurus documentation site.
31
37
32
38
templ has a code generation step, this is automatically carried out using `xc test`.
33
39
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.
40
+
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.
35
41
36
42
## Commit messages
37
43
@@ -63,6 +69,7 @@ Examples:
63
69
* Use the `xc fmt` and `xc lint` build tasks to format and lint code before committing.
64
70
* Don't use unnecessary comments that explain what the code does.
65
71
* If comments are used, ensure that they are full sentences, and use proper punctuation, including ending with a full stop.
72
+
* Don't write comments after the end of keywords, e.g. `continue // Only process pairs`
Copy file name to clipboardExpand all lines: docs/docs/03-syntax-and-usage/13-script-templates.md
+2Lines changed: 2 additions & 0 deletions
Display the source diff
Display the rich diff
Original file line number
Diff line number
Diff line change
@@ -15,6 +15,8 @@ templ body() {
15
15
}
16
16
```
17
17
18
+
If you have `prettierd`, `prettier` or `npx` on your `PATH`, `templ` will use it to format the `<script>` tag contents.
19
+
18
20
:::tip
19
21
To ensure that a `<script>` tag within a templ component is only rendered once per HTTP response (or context), use a [templ.OnceHandle](18-render-once.md).
@@ -211,6 +210,12 @@ local templ_format = function()
211
210
end
212
211
```
213
212
213
+
:::note
214
+
Formatting `script` and `style` elements in templ files is handed off to prettier.
215
+
216
+
If you don't have `prettierd`, `prettier` or `npx` on your path, formatting will not be applied to those elements.
217
+
:::
218
+
214
219
### Troubleshooting
215
220
216
221
If you cannot run `:TSInstall templ`, ensure you have an up-to-date version of [tree-sitter](https://github.com/nvim-treesitter/nvim-treesitter). The [package for templ](https://github.com/vrischmann/tree-sitter-templ) was [added to the main tree-sitter repository](https://github.com/nvim-treesitter/nvim-treesitter/pull/5667) so you shouldn't need to install a separate plugin for it.
0 commit comments