func(c *MainController)Get() {
c.TplName ="index.tpl"
c.Data["TrueCond"]=true
c.Data["FalseCound"]=false
typeustruct{
Namestring
Ageint
Sexstring
}
user:=&u{
"zhangsan",
1,
"nan",
}
c.Data["User"] = user
num:=[]int{1,2,3,4,5}
c.Data["Nums"]=num
c.Data["TplVar"]="hey guys"
c.Data["Html"]="
hey guys
"
c.Data["Pipe"]="
hey guys
"
}
{{if.TrueCond}}
true condition.
{{end}}
{{if .FalseCond}}
{{else}}
false condition.
{{end}}
{{with .User}}
{{.Name}};{{.Sex}}{{.Age}}
{{end}}
{{range .Nums}}
{{.}}
{{end}}
{{$tplVar := .TplVar}}
{{$tplVar}}
{{$html := .Html}}
{{$html}}
{{str2html .Html}}
{{.Pipe | htmlquote}}
{{template "test"}}
{{define "test"}}
this is a tpl test
{{end}}