mirror of
				https://github.com/Theodor-Springmann-Stiftung/musenalm.git
				synced 2025-10-30 01:35:32 +00:00 
			
		
		
		
	Introduced templating and views
This commit is contained in:
		
							
								
								
									
										32
									
								
								templating/helpers.go
									
									
									
									
									
										Normal file
									
								
							
							
						
						
									
										32
									
								
								templating/helpers.go
									
									
									
									
									
										Normal file
									
								
							| @@ -0,0 +1,32 @@ | ||||
| package templating | ||||
|  | ||||
| import "strings" | ||||
|  | ||||
| func PathToFSPath(p string) string { | ||||
| 	if p == "/" { | ||||
| 		return "." | ||||
| 	} | ||||
|  | ||||
| 	p = strings.TrimPrefix(p, "/") | ||||
| 	p = strings.TrimSuffix(p, "/") | ||||
|  | ||||
| 	return p | ||||
| } | ||||
|  | ||||
| func FSPathToPath(p string) string { | ||||
| 	if p == "." { | ||||
| 		return "/" | ||||
| 	} | ||||
|  | ||||
| 	p = strings.TrimPrefix(p, ".") | ||||
|  | ||||
| 	if !strings.HasPrefix(p, "/") { | ||||
| 		p = "/" + p | ||||
| 	} | ||||
|  | ||||
| 	if !strings.HasSuffix(p, "/") { | ||||
| 		p = p + "/" | ||||
| 	} | ||||
|  | ||||
| 	return p | ||||
| } | ||||
		Reference in New Issue
	
	Block a user
	 Simon Martens
					Simon Martens