Created
May 24, 2015 07:30
-
-
Save khoa-le/9b04a4f6be5969a23a82 to your computer and use it in GitHub Desktop.
Template Parse function in Golang html/template
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
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