gitlab.com/evatix-go/core@v1.3.55/internal/strutilinternal/ReplaceTemplateMap.go (about)

     1  package strutilinternal
     2  
     3  import (
     4  	"strings"
     5  )
     6  
     7  func ReplaceTemplateMap(
     8  	isCurly bool,
     9  	templateFormat string,
    10  	replacerMap map[string]string, // key ==> find, value ==> replace
    11  ) string {
    12  	if templateFormat == "" || len(replacerMap) == 0 {
    13  		return templateFormat
    14  	}
    15  
    16  	for finder, replacer := range replacerMap {
    17  		finderCurly := CurlyWrapIf(isCurly, finder)
    18  
    19  		templateFormat = strings.ReplaceAll(
    20  			templateFormat,
    21  			finderCurly,
    22  			replacer)
    23  	}
    24  
    25  	return templateFormat
    26  }