1
0
mirror of https://github.com/duke-git/lancet.git synced 2026-02-06 21:52:28 +08:00

feat: add TemplateReplace

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

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.
}