mirror of
https://github.com/Theodor-Springmann-Stiftung/kgpz_web.git
synced 2025-10-29 00:55:32 +00:00
added 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