sriracha/post.go
2023-04-20 20:03:02 -07:00

31 lines
442 B
Go

package sriracha
import "io"
type Post struct {
ID int
Thread int
Name string
Email string
Subject string
Message string
}
type renderPostData struct {
Post *Post
BaseURL string
}
func (p *Post) render(w io.Writer) error {
return templates.ExecuteTemplate(w, "post.gohtml", renderPostData{
Post: p,
BaseURL: "/",
})
}
func (p *Post) ThreadID() int {
if p.Thread == 0 {
return p.ID
}
return p.Thread
}