-
-
Notifications
You must be signed in to change notification settings - Fork 349
Closed
Description
Describe the bug
Since merging #1129 it's allowed to do something like this
<input type="text" value={ val } />
where val is an int. It will get converted automatically and rendered as
<input type="text" value="42">
However, if I do this
{{ attr := templ.Attributes{"type": "text, "value": 42} }}
<input { attr... } />
only the type attribute will get rendered:
<input type="text">
The culprit seems to be RenderAttributes in runtime.go, which in its switch statement only type-checks for string, *string, bool, *bool, KeyValue[string, bool], KeyValue[bool, bool] and func() bool.
Expected behavior
I'd expect attribute values stored in templ.Attributes (which is a map[string]any after all) to be treated the same as if I had specified them directly, that is passed through fmt.Sprint or something.
templ info output
(✓) os [ goos=linux goarch=amd64 ]
(✓) go [ location=/usr/local/go/bin/go version=go version go1.25rc1 linux/amd64 ]
(✓) gopls [ location=/home/chris/.local/bin/gopls version=golang.org/x/tools/gopls v0.19.1 ]
(✓) templ [ location=/home/chris/.local/bin/templ version=v0.3.906 ]
Reactions are currently unavailable
Metadata
Metadata
Assignees
Labels
No labels