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 errors if HTML attributes aren't quoted #963

Open
jvns opened this issue Oct 17, 2024 · 0 comments
Open

templ errors if HTML attributes aren't quoted #963

jvns opened this issue Oct 17, 2024 · 0 comments
Labels
enhancement New feature or request NeedsDecision Issue needs some more discussion so a decision can be made parser

Comments

@jvns
Copy link

jvns commented Oct 17, 2024

Describe the bug

If I try run templ on this file:

package main

templ Hello() {
  <div id=main></div>
}

I get this error:

parsing error: <div>: malformed open element: line 3, col 7

Seems related to #116 / #125.

Expected behavior

<div id=main></div> is valid HTML (this post discusses how unquoted attributed values are valid), so I expected templ to compile it even if it's a little unusual.

That said I noticed that the Elements documentation page documents ways in which templ diverges from HTML ("Unlike HTML, templ requires that all HTML elements are closed..."), so if this is intentional it might be good to document it.

templ info output

(✓) os [ goos=darwin goarch=arm64 ]
(✓) go [ location=/opt/homebrew/bin/go version=go version go1.23.1 darwin/arm64 ]
(✓) gopls [ location=/Users/bork/go/bin/gopls version=golang.org/x/tools/gopls v0.8.4
    golang.org/x/tools/[email protected] h1:zGZsAXAb0LLws/Z+2BCWR17dkPHhIO2GYwYSSkeXX5c= ]
(✓) templ [ location=/Users/bork/go/bin/templ version=v0.2.778 ]

Desktop (please complete the following information):

  • OS: Mac OS
  • templ CLI version? v0.2.778
  • Go version: 1.23
  • gopls version: v0.8.4
@joerdav joerdav added enhancement New feature or request parser NeedsDecision Issue needs some more discussion so a decision can be made labels Oct 18, 2024
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
enhancement New feature or request NeedsDecision Issue needs some more discussion so a decision can be made parser
Projects
None yet
Development

No branches or pull requests

2 participants