Skip to content

Commit

Permalink
add text render
Browse files Browse the repository at this point in the history
  • Loading branch information
chonglou committed May 11, 2017
1 parent f2560fb commit 020d002
Showing 1 changed file with 12 additions and 1 deletion.
13 changes: 12 additions & 1 deletion context.go
Original file line number Diff line number Diff line change
Expand Up @@ -4,7 +4,9 @@ import (
"context"
"net"
"net/http"
"path"
"strings"
"text/template"

"github.com/go-playground/form"
"github.com/unrolled/render"
Expand Down Expand Up @@ -93,11 +95,20 @@ func (p *Context) XML(s int, v interface{}) error {
return p.rdr.XML(p.Writer, s, v)
}

// HTML write xml
// HTML write html
func (p *Context) HTML(s int, t string, v interface{}) error {
return p.rdr.HTML(p.Writer, s, t, v)
}

// TEXT parse text template
func (p *Context) TEXT(s int, n string, v interface{}) error {
t, e := template.ParseFiles(path.Join("templates", n))
if e != nil {
return e
}
return t.Execute(p.Writer, v)
}

// Bind binds the passed struct pointer
func (p *Context) Bind(v interface{}) error {
e := p.Request.ParseForm()
Expand Down

0 comments on commit 020d002

Please sign in to comment.