a-h / templ

A language for writing HTML user interfaces in Go.
https://templ.guide/
MIT License
7.14k stars 236 forks source link

parser: style attribute of DOM element doesn't accept dynamic styles #785

Closed JWTappert closed 3 weeks ago

JWTappert commented 3 weeks ago

I am trying to pass some dynamic styles to a DOM element, in this case a <li> and I am getting parser errors. I've created a repo to illustrate the problem.

In this repo, in the the index.templ, within the for loop, when you remove the style attribute it works just fine so that tells me I am writing the dynamic class correctly but the same isn't true for the style attribute. Is this intentionally not supported? The CSS section of the docs doesn't mention this case explicitly.

When I run templ generate with the style attribute included I get this error:

Processing path: /home/jtappert/Workspace/templ-css
(!) templ version check failed: generator v0.2.543 is older than templ version v0.2.707 found in go.mod file, consider upgrading templ CLI
Generating production code: /home/jtappert/Workspace/templ-css
(✗) Error processing path: /home/jtappert/Workspace/templ-css/index.templ parsing error: for: expected nodes, but none were found: line 12, col 4
(✗) Generated code for 1 templates with 1 errors in 1.010371ms

I am happy to provide anymore information or answer any questions. Just let me know!

JWTappert commented 3 weeks ago

I am going to close this as I have learned about the discussion board and I see this discussion thread