mirror of
				https://gitee.com/gitea/gitea
				synced 2025-11-04 16:40:24 +08:00 
			
		
		
		
	Change all license headers to comply with REUSE specification. Fix #16132 Co-authored-by: flynnnnnnnnnn <flynnnnnnnnnn@github> Co-authored-by: John Olheiser <john.olheiser@gmail.com>
		
			
				
	
	
		
			34 lines
		
	
	
		
			772 B
		
	
	
	
		
			Go
		
	
	
	
	
	
			
		
		
	
	
			34 lines
		
	
	
		
			772 B
		
	
	
	
		
			Go
		
	
	
	
	
	
// Copyright 2022 The Gitea Authors. All rights reserved.
 | 
						|
// SPDX-License-Identifier: MIT
 | 
						|
 | 
						|
package html
 | 
						|
 | 
						|
// ParseSizeAndClass get size and class from string with default values
 | 
						|
// If present, "others" expects the new size first and then the classes to use
 | 
						|
func ParseSizeAndClass(defaultSize int, defaultClass string, others ...interface{}) (int, string) {
 | 
						|
	if len(others) == 0 {
 | 
						|
		return defaultSize, defaultClass
 | 
						|
	}
 | 
						|
 | 
						|
	size := defaultSize
 | 
						|
	_size, ok := others[0].(int)
 | 
						|
	if ok && _size != 0 {
 | 
						|
		size = _size
 | 
						|
	}
 | 
						|
 | 
						|
	if len(others) == 1 {
 | 
						|
		return size, defaultClass
 | 
						|
	}
 | 
						|
 | 
						|
	class := defaultClass
 | 
						|
	if _class, ok := others[1].(string); ok && _class != "" {
 | 
						|
		if defaultClass == "" {
 | 
						|
			class = _class
 | 
						|
		} else {
 | 
						|
			class = defaultClass + " " + _class
 | 
						|
		}
 | 
						|
	}
 | 
						|
 | 
						|
	return size, class
 | 
						|
}
 |