-
-
Notifications
You must be signed in to change notification settings - Fork 272
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
propsal: better support for comments in templ files #79
Comments
Yeah this would be nice just means altering the parser to skip it ? |
@gedw99 - Yes, but not skip it, add it as a new node type, so that it's retained during reformatting. I was thinking of basically the same sort of implementation as https://github.com/a-h/templ/blob/main/parser/v2/raw.go (script and style HTML elements) for the multi-line HTML comments, which just looks for the start and end tokens (i.e. if you see For the |
I noticed that the parser can't handle HTML in comments for example
will produce a error such as
|
Hi @aranw 👋🏻 nice to see you again, hope you're doing well! Are you using the latest commit? The latest tagged version doesn't have these changes in it yet. I added a new test based on what you were seeing and couldn't reproduce the issue: https://github.com/a-h/templ/actions/runs/6354142654 |
@a-h 👋🏻 I'm using tagged version v0.2.334 I'll try make a reproducible test in a fork give me a few minutes |
I was planning to do a new release, quite a few improvements in since the last tagged release. |
@a-h the following example here breaks when I run generate Edit: I did it like this as I wasn't sure exactly where in the parser code a test for this would make sense. I've not really looked through the source code too much yet. Mostly just been experimenting with converting go templates to templ right now |
Ah yeah I'm not running the latest version that has definitely fixed the issue! |
For Go comments within the template section, I think this might be the place to start... https://github.com/a-h/templ/tree/issue_159_go_comments_before_package Was aiming to solve issue 159, and there's some crossover with this. @tantalic - have you started on this one yet? Feel free to disregard my thoughts or work on top if you want to pick it up. Just let me know! |
@a-h I have not started anything on go style comments, at least not yet. The next couple of weeks are pretty busy so I don't think I will be jumping in soon on this if anyone else wants to work on it! |
Currently, HTML comments and Go comments are not well supported. Would be good to have them as an option.
The text was updated successfully, but these errors were encountered: