-
Notifications
You must be signed in to change notification settings - Fork 27
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
added DataAttr and DataAttrs function #78
Conversation
attrs/utils_test.go
Outdated
@@ -0,0 +1,20 @@ | |||
package attrs_test |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
This can just be package attrs
then you can remove the attrs.
from usage in this file.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Fixed!
attrs/utils.go
Outdated
} | ||
|
||
// Return Props of data attributes build from given name-value pairs | ||
func DataAttrs(pairs map[string]string) Props { |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Great idea on also adding a way to add multiple considering these may be less unique that other attributes! What do you think about introducing a reusable type named KeyValueMap
or something similar, to avoid constantly writing map[string]string
? It could streamline things for users. However, I'm a bit cautious about adding complexity that might make the library harder for developers to grasp. What do you think? Is the trade-off worth it?
attrs/utils.go
Outdated
|
||
import "strings" | ||
|
||
// Return name for a data attribute |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Go convention is to start comments with the function name. It's helps godoc
generate documentation. Can we change the comments to // DataAttr returns the name for a data attribute.
please?
attrs/utils.go
Outdated
return builder.String() | ||
} | ||
|
||
// Return Props of data attributes build from given name-value pairs |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Same note on comment here. Thanks!
attrs/utils.go
Outdated
} | ||
|
||
// DataAttrs returns Props of data attributes build from given name-value pairs | ||
func DataAttrs(pairs map[string]string) Props { |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Looks good, thanks @whisk !
Issue: #73
Example usage: