Enha: index.html to template
This commit is contained in:
@ -1,3 +1,4 @@
|
||||
{{define "main"}}
|
||||
<!DOCTYPE html>
|
||||
<html lang="en">
|
||||
<head>
|
||||
@ -26,3 +27,4 @@
|
||||
</div>
|
||||
</body>
|
||||
</html>
|
||||
{{end}}
|
||||
|
@ -18,6 +18,10 @@ func HandlePing(w http.ResponseWriter, r *http.Request) {
|
||||
}
|
||||
|
||||
func HandleHome(w http.ResponseWriter, r *http.Request) {
|
||||
tmpl := template.Must(template.ParseFiles("components/index.html"))
|
||||
tmpl.Execute(w, roundWords)
|
||||
tmpl, err := template.ParseGlob("components/*.html")
|
||||
if err != nil {
|
||||
abortWithError(w, err.Error())
|
||||
return
|
||||
}
|
||||
tmpl.ExecuteTemplate(w, "main", roundWords)
|
||||
}
|
||||
|
Reference in New Issue
Block a user