code.gitea.io/gitea@v1.19.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 ...interface{}) (int, string) {
     9  	if len(others) == 0 {
    10  		return defaultSize, defaultClass
    11  	}
    12  
    13  	size := defaultSize
    14  	_size, ok := others[0].(int)
    15  	if ok && _size != 0 {
    16  		size = _size
    17  	}
    18  
    19  	if len(others) == 1 {
    20  		return size, defaultClass
    21  	}
    22  
    23  	class := defaultClass
    24  	if _class, ok := others[1].(string); ok && _class != "" {
    25  		if defaultClass == "" {
    26  			class = _class
    27  		} else {
    28  			class = defaultClass + " " + _class
    29  		}
    30  	}
    31  
    32  	return size, class
    33  }