mirror of
https://github.com/unknwon/the-way-to-go_ZH_CN.git
synced 2025-08-12 03:55:28 +08:00
04.4.md
This commit is contained in:
14
eBook/examples/chapter_15/predefined_functions.go
Normal file
14
eBook/examples/chapter_15/predefined_functions.go
Normal file
@@ -0,0 +1,14 @@
|
||||
// predefined_functions.go
|
||||
package main
|
||||
|
||||
import (
|
||||
"os"
|
||||
"text/template"
|
||||
)
|
||||
|
||||
func main() {
|
||||
t := template.New("test")
|
||||
t = template.Must(t.Parse("{{with $x := `hello`}}{{printf `%s %s` $x `Mary`}}{{end}}!\n"))
|
||||
t.Execute(os.Stdout, nil)
|
||||
}
|
||||
// hello Mary!
|
Reference in New Issue
Block a user