summaryrefslogtreecommitdiff
path: root/tpls.go
blob: 10f432242e02e309b7f54f65ff2a52c5730d5b34 (plain)
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
package main

import (
	"html/template"
	"log"
	"path"
)

func loadTpl(tplpath, name string) *template.Template {
	tpl, err := template.ParseFiles(
		path.Join(tplpath, "master.tpl"),
		path.Join(tplpath, name+".tpl"))
	if err != nil {
		log.Fatalf("Could not load template \"%s\": %s", name, err)
	}
	return tpl
}

var (
	tplRegister *template.Template
	tplMsg      *template.Template
	tplLogin    *template.Template
)

func initTpls() {
	tplpath, err := conf.GetString("paths", "tpls")
	if err != nil {
		log.Fatalf("Could not get paths.tpls config: %s", err)
	}

	tplRegister = loadTpl(tplpath, "register")
	tplMsg = loadTpl(tplpath, "msg")
	tplLogin = loadTpl(tplpath, "login")
}

type msgTpldata struct {
	Title, Class, Msg string
}