feat: add TemplateReplace

This commit is contained in:
dudaodong committed 2024-09-06 11:04:54 +08:00
1 parent f9e5ec9096
commit 93be25920f
5 files changed
+151 -1

No files matched your search

+15
View File
@@ -724,3 +724,18 @@ func ExampleRotate() {
// oHell
// loHel
}
func ExampleTemplateReplace() {
template := `Hello, my name is {name}, I'm {age} years old.`
data := map[string]string{
"name": "Bob",
"age": "20",
}
result := TemplateReplace(template, data)
fmt.Println(result)
// Output:
// Hello, my name is Bob, I'm 20 years old.
}