utils.go 406 B

123456789101112131415161718192021222324
  1. package vuetify
  2. import (
  3. "strings"
  4. h "github.com/theplant/htmlgo"
  5. )
  6. func stringsTrim(vs ...string) (r []string) {
  7. for _, v := range vs {
  8. if cv := strings.TrimSpace(v); len(cv) > 0 {
  9. r = append(r, cv)
  10. }
  11. }
  12. return
  13. }
  14. func SetErrorMessages(t h.MutableAttrHTMLComponent, vs []string) {
  15. cvs := stringsTrim(vs...)
  16. if len(cvs) == 0 {
  17. return
  18. }
  19. t.SetAttr(":error-messages", h.JSONString(cvs))
  20. }