Skip to content

inconsistent formatting for multi-line go code in templ block #1116

@anuragkumar19

Description

@anuragkumar19

Describe the bug
Inconsistent formatting of go code inside {{ }} in templ block.

To Reproduce

templ Collapse(p *CollapseParams) {
	{{
	if p == nil {    // <--- add or remove tabs to see formatting changing
		p = &CollapseParams{}
	}
	p.merge()
	}}
	@As(p.As, p.Attrs) {
		{ children... }
	}
}

Expected behavior
Should be formatted same each time.

Screenshots
Image

templ info output
(✓) os [ goos=linux goarch=amd64 ]
(✓) go [ location=/usr/local/go/bin/go version=go version go1.24.1 linux/amd64 ]
(✓) gopls [ location=/home/anurag/go/bin/gopls version=golang.org/x/tools/gopls v0.18.1 ]
(✓) templ [ location=/home/anurag/go/bin/templ version=v0.3.857 ]

Desktop (please complete the following information):

  • OS: WSL
  • templ CLI version: v0.3.857
  • Go version: go version go1.24.1 linux/amd64
  • gopls version: golang.org/x/tools/gopls v0.18.1

Metadata

Metadata

Assignees

No one assigned

    Labels

    No labels
    No labels

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions