Closed tommsawyer closed 2 months ago
Something like this would be awesome out of the box, thanks!
I've added the solution to my own dotfiles here for the time-being. It works great except for one thing - the templ builtin function templ myComponent() {
will be commented like <!-- templ myComponent() { -->
. Is that something we could accommodate for?
Hey, thanks for the PR! Supporting templ makes a lot of sense since it seems to be very similar to JSX.
In order to handle the templ myComponent() {
line correctly, I think that we can use component_block
instead of component_declaration
as the node.
If we wanted to have a bit more robust support for templ, then we could also handle this case (but it's probably not required yet). What should happen in the following lines?
package main
templ hello(name string) {
<div>
<h1>Howdy foks</h1>
Hello, { name }
<hr style="padding: 10px"
if true { <-- this line, for example, and the next one
class="itIsTrue"
}
/>
</div>
}
Here's how it would work with component_block
:
Hello! Any plan to merge this PR soon? :)
Merged and pushed the small fix myself, thanks for the reminder 👍
Added basic support for templ files. Docs for templ commenting here: https://templ.guide/syntax-and-usage/comments
In general we are using html-style comments inside components, and go-style comments outside.