This will take all your (found within the ) and add them to your executable application at compile time – so it’s fast as it doesn’t have to read from file. You can call these templates with ExecuteTemplate and passing the file name as the second parameter.
If you’re using this with a web server, you can replace the os.Stdout with the net/http writer.
package main import ( "/template" "log" "os" ) type Page struct { Title string } var templates = template.



Source link

LEAVE A REPLY

Please enter your comment!
Please enter your name here