mirror of
https://gitlab.dit.htwk-leipzig.de/htwk-software/htwkalender.git
synced 2025-08-03 10:19:14 +02:00
Feature Template Module Titles (Test)
This commit is contained in:
23
backend/service/names/userDefinedNameTemplates.go
Normal file
23
backend/service/names/userDefinedNameTemplates.go
Normal file
@@ -0,0 +1,23 @@
|
||||
package names
|
||||
|
||||
import (
|
||||
"htwkalender/model"
|
||||
"regexp"
|
||||
)
|
||||
|
||||
func ReplaceTemplateSubStrings(rawString string, event model.Event) string {
|
||||
re := regexp.MustCompile(`\%(.)`)
|
||||
|
||||
return re.ReplaceAllStringFunc(rawString, func(match string) string {
|
||||
switch match {
|
||||
case "%%":
|
||||
return "%"
|
||||
case "%t":
|
||||
return event.EventType
|
||||
case "%p":
|
||||
return event.Compulsory
|
||||
default:
|
||||
return match
|
||||
}
|
||||
})
|
||||
}
|
Reference in New Issue
Block a user