forked from goffee/core
theme base system
This commit is contained in:
parent
1172e23c16
commit
465e88bf40
7 changed files with 74 additions and 51 deletions
15
response.go
15
response.go
|
|
@ -6,6 +6,7 @@
|
|||
package core
|
||||
|
||||
import (
|
||||
"bytes"
|
||||
"fmt"
|
||||
"net/http"
|
||||
)
|
||||
|
|
@ -63,6 +64,20 @@ func (rs *Response) HTML(body string) *Response {
|
|||
return rs
|
||||
}
|
||||
|
||||
// TODO add doc
|
||||
func (rs *Response) Template(name string, data interface{}) *Response {
|
||||
var buffer bytes.Buffer
|
||||
if rs.isTerminated == false {
|
||||
err := tmpl.ExecuteTemplate(&buffer, name, data)
|
||||
if err != nil {
|
||||
panic(fmt.Sprintf("error executing template: %v", err))
|
||||
}
|
||||
rs.contentType = CONTENT_TYPE_HTML
|
||||
buffer.WriteTo(rs.HttpResponseWriter)
|
||||
}
|
||||
return rs
|
||||
}
|
||||
|
||||
// TODO add doc
|
||||
func (rs *Response) SetStatusCode(code int) *Response {
|
||||
if rs.isTerminated == false {
|
||||
|
|
|
|||
Loading…
Add table
Add a link
Reference in a new issue