I am trying to change the default delimiters for Golang hml templates and here is the code I am using now:
func indexHandler(w http.ResponseWriter, r *http.Request) {
pageFile := "html/testpage.html"
tmpl, err := template.New(pageFile).Delims("[[", "]]").ParseFiles(pageFile)
//tmpl := template.Must(template.ParseFiles(pageFile))
if (err!=nil){
fmt.Println("Error")
fmt.Println(err)
}
tmpl.Execute(w, nil)
}
The above code renders a blank page in the browser. It will render properly if I use the commented out code instead of the second line.
Here is the template page source:
<!doctype html>
<html lang="en">
<head>
<meta charset="utf-8">
<title>The HTML5 </title>
<meta name="description" content="HTML5">
<meta name="author" content="Test">
</head>
<body>
This is html page
</body>
</html>
My go version is: go version go1.10.2 linux/amd64
I run it by go run test.go
test.go being in the main package
There is no error message being printed in the browser or the terminal.
What am I missing here?