elem-go
elem-go copied to clipboard
Add ` ClassNames` util to `attrs` package
Closes: https://github.com/chasefleming/elem-go/issues/165
@whisk what do you think about this? Do you mind reviewing?
hi @chasefleming,
I think that your point about missing spaces is valid. Concatenation of strings with + is error prone, and that's why I usually use something like
strings.Join([]string{"btn", elem.If(isPrimary, "primary", "")}, " ")
This is not exactly neat and may add redundant spaces, but it's safe.
Can ClassNames be generalized for other attrs which may need multiple values separated by spaces? I can't think of any right now.
Otherwise the PR looks good ~~with one minor comment~~ with no comments :)