-
-
Notifications
You must be signed in to change notification settings - Fork 304
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
templ fmt does not indent style tag properly #1010
Comments
Happy to take this on. |
So I've been trying to get a little more familiar with this issue. I've mainly been focusing my efforts in generator.go around indent levels. From the code example provided, it looks like the style tag is not indenting child nodes as we expect, and its closing tag. Knowing that, I think the issue is inside either writeTemplBuffer, writeTemplate, or writeNode. I will keep poking around for now but could probably use some confirmation I'm at least looking in the right area. And just so we're on the same page, this is what the expected result should be, right? templ leftRight(left templ.Component, right templ.Component) {
<style>
body {
background: black;
}
</style>
<div class="flex flex-col items-center justify-center h-screen">
<div></div>
<div class="flex flex-row">
@left
@right
</div>
<div>
Se priser
</div>
</div>
} |
I think this does the same thing with |
So, you've probably figured out that You can see that in action here: templ/cmd/templ/fmtcmd/main.go Lines 141 to 166 in 8501201
Note that the Lines 128 to 150 in 8501201
So you can see that each The script and style elements are parsed into the following types: Lines 669 to 703 in 8501201
By this parsing code: https://github.com/a-h/templ/blob/850120161a0434ee73b92810f02e4def8a70c850/parser/v2/raw.go I can see that the style and script tags don't populate out a templ/parser/v2/elementparser.go Line 496 in 8501201
I think ths issue is probably:
Note that there's some formatting tests alonside the Hope that helps you track it down! |
Say I have the following code

After running
templ fmt .
it will look like this.So the divs and such are are indented correctly, but the closing style tag with content is not.
Please let me know if more info is needed.

templ info
outputThe text was updated successfully, but these errors were encountered: