|
@@ -1,12 +1,22 @@
|
1
|
1
|
package handlers
|
2
|
2
|
|
3
|
3
|
import (
|
|
4
|
+ "html/template"
|
|
5
|
+ "log"
|
4
|
6
|
"net/http"
|
5
|
7
|
"os"
|
6
|
|
-
|
7
|
|
- "github.com/isomorphicgo/isogoapp/view"
|
8
|
8
|
)
|
9
|
9
|
|
|
10
|
+// Template rendering function
|
|
11
|
+func RenderTemplate(w http.ResponseWriter, templateFile string, templateData interface{}) {
|
|
12
|
+
|
|
13
|
+ t, err := template.ParseFiles(templateFile)
|
|
14
|
+ if err != nil {
|
|
15
|
+ log.Fatal("Error encountered while parsing the template: ", err)
|
|
16
|
+ }
|
|
17
|
+ t.Execute(w, templateData)
|
|
18
|
+}
|
|
19
|
+
|
10
|
20
|
func IndexHandler(w http.ResponseWriter, r *http.Request) {
|
11
|
|
- view.RenderTemplate(w, os.Getenv("ISOGO_APP_ROOT")+"/templates/index.tmpl", nil)
|
|
21
|
+ RenderTemplate(w, os.Getenv("ISOGO_APP_ROOT")+"/templates/index.tmpl", nil)
|
12
|
22
|
}
|