Skip to content
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 removes significant white space inside <pre> tags #937

Open
AdrienHorgnies opened this issue Sep 27, 2024 · 0 comments
Open

Templ removes significant white space inside <pre> tags #937

AdrienHorgnies opened this issue Sep 27, 2024 · 0 comments

Comments

@AdrienHorgnies
Copy link

Before you begin
Please make sure you're using the latest version of the templ CLI (go install github.com/a-h/templ/cmd/templ@latest), and have upgraded your project to use the latest version of the templ runtime (go get -u github.com/a-h/templ@latest)

Describe the bug
The following template:

<pre>
	command line 1;
	command line 2;
</pre>

is rendered to

<pre>command line 1; command line 2;</pre>

which is incorrect as the pre tag exists to make white space significant.

To Reproduce

go.mod

module templ.demo

go 1.23.1

require github.com/a-h/templ v0.2.778 // direct

go.sum

github.com/a-h/templ v0.2.778 h1:VzhOuvWECrwOec4790lcLlZpP4Iptt5Q4K9aFxQmtaM=
github.com/a-h/templ v0.2.778/go.mod h1:lq48JXoUvuQrU0VThrK31yFwdRjTCnIE5bcPCM9IP1w=

demo.templ

package main 

templ Demo() {
    <pre>
        command line 1;
        command line 2;
    </pre>
}

main.go

package main

import (
	"context"
	"os"
)

func main() {
	ctx := context.Background()
	w, _ := os.OpenFile("demo.html", os.O_WRONLY|os.O_CREATE|os.O_TRUNC, 0644)
	Demo().Render(ctx, w)
}

Run main and cat "demo.html"

<pre>command line 1; command line 2;</pre>

Expected behavior
The whitespaces inside <pre> and </pre> should be kept as is:

<pre>
        command line 1;
        command line 2;
    </pre>

Screenshots
N/A

Logs
N/A

templ info output
Run templ info and include the output.
(✓) os [ goos=linux goarch=amd64 ]
(✓) go [ location=/usr/local/bin/go version=go version go1.23.1 linux/amd64 ]
(✗) gopls [ location= version= message=failed to find gopls: cannot find gopls on the path (REDACTED), in $HOME/go/bin or $HOME/.local/bin/gopls. You can install gopls with go install golang.org/x/tools/gopls@latest ]
(✓) templ [ location=/usr/local/bin/templ version=v0.2.778 ]

Desktop (please complete the following information):

  • OS:
PRETTY_NAME="Ubuntu 24.04.1 LTS"
NAME="Ubuntu"
VERSION_ID="24.04"
VERSION="24.04.1 LTS (Noble Numbat)"
VERSION_CODENAME=noble
ID=ubuntu
ID_LIKE=debian
HOME_URL="https://www.ubuntu.com/"
SUPPORT_URL="https://help.ubuntu.com/"
BUG_REPORT_URL="https://bugs.launchpad.net/ubuntu/"
PRIVACY_POLICY_URL="https://www.ubuntu.com/legal/terms-and-policies/privacy-policy"
UBUNTU_CODENAME=noble
LOGO=ubuntu-logo
  • templ CLI version (templ version): v0.2.778
  • Go version (go version): go version go1.23.1 linux/amd64
  • gopls version (gopls version): N/A

Additional context
N/A

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

No branches or pull requests

1 participant