-
-
Notifications
You must be signed in to change notification settings - Fork 349
Closed
Description
Describe the bug
templ fmt adds whitespace to newlines when the line is:
- inside an inline func
- being used to set a struct value
- that is being passed as input to another templ component
To Reproduce
type Params struct {
Foo string
}
templ Child(p Params) {
<p>{ p.Foo }</p>
}
templ Parent(p Params) {
{{
bar := (func() string {
if p.Foo == "" {
return "Bar"
}
// no whitespace added here
return p.Foo
})()
baz := Params{
Foo: (func() string {
if p.Foo == "" {
return "Baz"
}
// no whitespace added here
return p.Foo
})(),
}
}}
<div>
@Child(Params{
Foo: (func() string {
if p.Foo == "" {
return "Foo"
}
// <-- whitespace added to blank line here after `fmt` // remove comments to test
return p.Foo
})(),
})
<p>{ bar }</p>
<p>{ baz.Foo }</p>
</div>
}Expected behavior
No whitespace is added to the blank line inside the inline func
If any whitespace is present in this blank line, then it should be removed.
Desktop (please complete the following information):
- OS: MacOS
- templ CLI version v0.3.871
- Go version 1.24.2
goplsversion v0.18.1
Additional context
I'm looking to use templ fmt in CI.
Reactions are currently unavailable
Metadata
Metadata
Assignees
Labels
No labels