You can not select more than 25 topics Topics must start with a letter or number, can include dashes ('-') and can be up to 35 characters long.

html.go 638B

12345678910111213141516171819202122232425
  1. // Copyright 2022 The Gitea Authors. All rights reserved.
  2. // SPDX-License-Identifier: MIT
  3. package html
  4. // ParseSizeAndClass get size and class from string with default values
  5. // If present, "others" expects the new size first and then the classes to use
  6. func ParseSizeAndClass(defaultSize int, defaultClass string, others ...any) (int, string) {
  7. size := defaultSize
  8. if len(others) >= 1 {
  9. if v, ok := others[0].(int); ok && v != 0 {
  10. size = v
  11. }
  12. }
  13. class := defaultClass
  14. if len(others) >= 2 {
  15. if v, ok := others[1].(string); ok && v != "" {
  16. if class != "" {
  17. class += " "
  18. }
  19. class += v
  20. }
  21. }
  22. return size, class
  23. }