Feature Template Module Titles (Test)

This commit is contained in:
survellow
2023-10-18 00:53:06 +02:00
parent 01e32448c9
commit ccd164bb07
8 changed files with 289 additions and 24 deletions

View 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
}
})
}