-
-
Notifications
You must be signed in to change notification settings - Fork 280
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
generator: Spread under attribute #611
Comments
I think for this case, using <button class={ strings.Join([]string{"foo"}, " ") }>Button</button> |
For that specific case yes but the problem appeared when i was trying to use |
@iamajoe Would the
This should work for slices of not only strings. |
Hm. I haven't tried. I will take a look. Still not the best solution in my opinion since it is one more abstraction you need to know on top of the syntax but I understand the difficulty in implementing what I am talking about. |
On the contrary, I think this is one less abstraction to remember. A spread inside curly braces is not something you would see in Go Although I do understand this requires knowledge of a new function. |
And the error:
I could use For this to function I had to do this nastiness: func convertCSSClassToClasses(css ...templ.CSSClass) templ.CSSClasses {
var cssClasses []any = make([]any, len(css))
for i, v := range css {
cssClasses[i] = v.(any)
}
return templ.Classes(cssClasses...)
} I guess |
I wouldn't be opposed to classes being generic. Another approach would be to just support That way you could do:
You wouldn't even have to spread. |
There is a case where you might want to have a spread on an attribute.
Example:
This error comes in if i use this:
If I generate like this instead:
Creates:
Looking at the generation, it seems that supporting spread operator shouldn't be a problem. Some kind of parsing issue?!
The text was updated successfully, but these errors were encountered: