mirror of
https://github.com/skoelle/kctl-tui.git
synced 2026-09-17 20:10:24 +00:00
20 lines
668 B
Go
20 lines
668 B
Go
// Copyright (c) 2026 Stefan Koelle (https://stefankoelle.de)
|
|
// Licensed under the MIT License. See LICENSE file in project root for details.
|
|
|
|
package kctl
|
|
|
|
import "strings"
|
|
|
|
// ResolveTemplate replaces "{key}" placeholders in template with the
|
|
// corresponding value from values. Placeholders with no matching key are
|
|
// left untouched, so a misconfigured template is visible (e.g. a literal
|
|
// "{typo}" in the result) instead of silently collapsing to an empty
|
|
// string.
|
|
func ResolveTemplate(template string, values map[string]string) string {
|
|
result := template
|
|
for k, v := range values {
|
|
result = strings.ReplaceAll(result, "{"+k+"}", v)
|
|
}
|
|
return result
|
|
}
|