2,348
社区成员




tmpl, err := template.ParseFiles("index.tpl")
if err != nil {
fmt.Println("err")
panic(err)
}
fmt.Println(tmpl.Name())
name := "index"
tmpl.Delims("<%", "%>").Execute(w, name)
fmt.Println("Works")
<!DOCTYPE html>
<html>
<head>
<meta http-equiv="Content-Type" content="text/html; charset=utf-8">
<script type="text/javascript" src="/static/js/main.js"></script>
<title>layout</title>
</head>
<body>
<h3>This is layout <b/>
template data: {{ . }} </h3>
</body>
</html>