-
Notifications
You must be signed in to change notification settings - Fork 13
/
template_doc.go
36 lines (30 loc) · 922 Bytes
/
template_doc.go
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
package plugins
import (
"io"
"path"
"github.com/osteele/liquid"
)
type templateDoc struct {
site Site
path string
tpl *liquid.Template
}
func (d *templateDoc) Permalink() string { return "/" + d.path }
func (d *templateDoc) SourcePath() string { return "" }
func (d *templateDoc) OutputExt() string { return path.Ext(d.path) }
func (d *templateDoc) Published() bool { return true }
func (d *templateDoc) Static() bool { return false } // FIXME means different things to different callers
func (d *templateDoc) Categories() []string { return []string{} }
func (d *templateDoc) Tags() []string { return []string{} }
func (d *templateDoc) Content() []byte {
bindings := map[string]interface{}{"site": d.site}
b, err := d.tpl.Render(bindings)
if err != nil {
panic(err)
}
return b
}
func (d *templateDoc) Write(w io.Writer) error {
_, err := w.Write(d.Content())
return err
}