Skip to content

Instantly share code, notes, and snippets.

@khoa-le
Created May 24, 2015 07:30
Show Gist options
  • Save khoa-le/9b04a4f6be5969a23a82 to your computer and use it in GitHub Desktop.
Save khoa-le/9b04a4f6be5969a23a82 to your computer and use it in GitHub Desktop.
Template Parse function in Golang html/template
package main
import (
"fmt"
"html/template"
"os"
)
func main() {
t := template.New("HELLO")
var templates = template.Must(t.ParseFiles("defaultTemplate.html"))
data := map[string]interface{}{
"Title": "Hello World!",
}
templates.ExecuteTemplate(os.Stdout, "defaultTemplate.html", data)
fmt.Println("\n\n")
fmt.Println("Template name is : ", t.Name())
}
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment