mirror of
				https://github.com/go-gitea/gitea
				synced 2025-11-03 21:08:25 +00:00 
			
		
		
		
	Move svg html render to modules/svg (#21716)
Also added more checks for the render function. Co-authored-by: silverwind <me@silverwind.io>
This commit is contained in:
		
							
								
								
									
										34
									
								
								modules/html/html.go
									
									
									
									
									
										Normal file
									
								
							
							
						
						
									
										34
									
								
								modules/html/html.go
									
									
									
									
									
										Normal file
									
								
							@@ -0,0 +1,34 @@
 | 
			
		||||
// Copyright 2022 The Gitea Authors. All rights reserved.
 | 
			
		||||
// Use of this source code is governed by a MIT-style
 | 
			
		||||
// license that can be found in the LICENSE file.
 | 
			
		||||
 | 
			
		||||
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
 | 
			
		||||
}
 | 
			
		||||
		Reference in New Issue
	
	Block a user