summaryrefslogtreecommitdiff
path: root/tpls.go
blob: a86166479871abad306d3e2a5130381966b9ca2f (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
39
40
41
42
43
44
45
46
47
48
49
50
package main

import (
	"github.com/kch42/mailremind/confhelper"
	"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
	tplReallyDelete *template.Template
	tplPwreset      *template.Template
	tplForgotpw     *template.Template
	tplJobs         *template.Template
	tplJobedit      *template.Template
	tplSettings     *template.Template
	tplIndex        *template.Template
)

func initTpls() {
	tplpath := confhelper.ConfStringOrFatal(conf, "paths", "tpls")

	tplRegister = loadTpl(tplpath, "register")
	tplMsg = loadTpl(tplpath, "msg")
	tplLogin = loadTpl(tplpath, "login")
	tplReallyDelete = loadTpl(tplpath, "reallydelete")
	tplPwreset = loadTpl(tplpath, "pwreset")
	tplForgotpw = loadTpl(tplpath, "forgotpw")
	tplJobs = loadTpl(tplpath, "jobs")
	tplJobedit = loadTpl(tplpath, "jobedit")
	tplSettings = loadTpl(tplpath, "settings")
	tplIndex = loadTpl(tplpath, "index")
}

type msgTpldata struct {
	Title, Class, Msg string
}