Skip to content

Commit

Permalink
Merge pull request #2 from kolomiichenko/js
Browse files Browse the repository at this point in the history
Add JS templating
  • Loading branch information
night-codes authored Nov 7, 2018
2 parents 27987c1 + 0ea0fc0 commit 860e148
Show file tree
Hide file tree
Showing 2 changed files with 7 additions and 0 deletions.
6 changes: 6 additions & 0 deletions context.go
Original file line number Diff line number Diff line change
Expand Up @@ -376,6 +376,12 @@ func (c *Context) XML(statusCode int, obj interface{}) {
c.engine.Render.XML(c.RequestCtx, statusCode, obj)
}

// JS renders the JS template specified by its file name.
// It also updates the HTTP code and sets the Content-Type as "text/javascript".
func (c *Context) JS(statusCode int, name string, obj interface{}) {
c.engine.Render.JS(c.RequestCtx, statusCode, name, obj)
}

// String writes the given string into the response body.
func (c *Context) String(statusCode int, format string, values ...interface{}) {
c.SetStatusCode(statusCode)
Expand Down
1 change: 1 addition & 0 deletions engine.go
Original file line number Diff line number Diff line change
Expand Up @@ -23,6 +23,7 @@ type (
JSONP(*fasthttp.RequestCtx, int, string, interface{}) error
HTML(*fasthttp.RequestCtx, int, string, interface{}, ...string) error
XML(*fasthttp.RequestCtx, int, interface{}) error
JS(*fasthttp.RequestCtx, int, string, interface{}, ...string) error
}

// Handler is the function for handling HTTP requests.
Expand Down

0 comments on commit 860e148

Please sign in to comment.