...
1 package sriracha
2
3 import "io"
4
5 type Post struct {
6 ID int
7 Thread int
8 Name string
9 Email string
10 Subject string
11 Message string
12 }
13
14 type renderPostData struct {
15 Post *Post
16 BaseURL string
17 }
18
19 func (p *Post) render(w io.Writer) error {
20 return templates.ExecuteTemplate(w, "post.gohtml", renderPostData{
21 Post: p,
22 BaseURL: "/",
23 })
24 }
25
26 func (p *Post) ThreadID() int {
27 if p.Thread == 0 {
28 return p.ID
29 }
30 return p.Thread
31 }
32
View as plain text