YTSFlix_Go/templates/templates.go

51 lines
1.0 KiB
Go
Raw Normal View History

2018-11-04 14:58:15 +00:00
package templates
import (
"github.com/gobuffalo/packr"
"github.com/sirupsen/logrus"
"html/template"
)
var box = packr.NewBox("./../static")
func HomeTemplate() *template.Template {
t := template.New("index.html")
var err error
t, err = t.Parse(box.String("index.html"))
if err != nil {
logrus.Fatal(err)
}
t, err = t.Parse(box.String("nav.html"))
//t, err = t.ParseFiles("./static/index.html", "./static/nav.html")
if err != nil {
logrus.Fatal(err)
}
return t
}
func MovieTemplate() *template.Template {
t := template.New("movie.html")
var err error
t, err = t.Parse(box.String("movie.html"))
if err != nil {
logrus.Fatal(err)
}
t, err = t.Parse(box.String("nav.html"))
//t, err = t.ParseFiles("./static/movie.html", "./static/nav.html")
if err != nil {
logrus.Fatal(err)
}
return t
}
func WatchTemplate() *template.Template {
t := template.New(box.String("watch.html"))
var err error
t, err = t.Parse(box.String("watch.html"))
//t, err = t.ParseFiles("./static/watch.html")
if err != nil {
logrus.Fatal(err)
}
return t
}