~reesmichael1/chantpointer

4537fd2b6938a849a869f51bb00f8d2b79be947d — Michael Rees 3 years ago 1c509b3
Differentiate between text/template and html/template
1 files changed, 4 insertions(+), 3 deletions(-)

M handlers.go
M handlers.go => handlers.go +4 -3
@@ 1,8 1,9 @@
package main

import (
	htmlTemplate "html/template"
	"net/http"
	"text/template"
	textTemplate "text/template"
)

// GenerateHandler handles incoming requests to the generate endpoint


@@ 12,7 13,7 @@ func GenerateHandler(w http.ResponseWriter, r *http.Request) {
		return
	}

	t, err := template.ParseFiles("templates/psalm.tem")
	t, err := textTemplate.ParseFiles("templates/psalm.tem")
	if err != nil {
		http.Error(w, err.Error(), http.StatusInternalServerError)
		return


@@ 33,7 34,7 @@ func GenerateHandler(w http.ResponseWriter, r *http.Request) {

// IndexHandler handles incoming requests to the generate endpoint
func IndexHandler(w http.ResponseWriter, r *http.Request) {
	t, err := template.ParseFiles("templates/html/index.html")
	t, err := htmlTemplate.ParseFiles("templates/html/index.html")
	if err != nil {
		http.Error(w, err.Error(), http.StatusInternalServerError)
		return