blob: 2581da0f3b8bbc8e61834228e47dae283eb60b5e (
plain) (
blame)
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
|
package koushin
import (
"html/template"
"io"
"net/url"
"github.com/labstack/echo/v4"
)
type tmpl struct {
t *template.Template
}
func (t *tmpl) Render(w io.Writer, name string, data interface{}, c echo.Context) error {
return t.t.ExecuteTemplate(w, name, data)
}
func loadTemplates() (*tmpl, error) {
t, err := template.New("drmdb").Funcs(template.FuncMap{
"tuple": func(values ...interface{}) []interface{} {
return values
},
"pathescape": func(s string) string {
return url.PathEscape(s)
},
}).ParseGlob("public/*.html")
return &tmpl{t}, err
}
|