code.gitea.io/gitea@v1.22.3/modules/html/html.go (about)

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