Add Handler & Templates interface (#412)

* Add new supporter
* Add new test condition
* Add Handler Type
* Update Templates Interface
pull/417/head
fenny 2020-05-25 07:31:20 -04:00 committed by GitHub
parent e8b8fdfb35
commit 02b4061b44
No known key found for this signature in database
GPG Key ID: 4AEE18F83AFDEB23
2 changed files with 7 additions and 7 deletions

4
app.go
View File

@ -94,8 +94,8 @@ type Settings struct {
// When set to true, it will not print out the fiber ASCII and "listening" on message
DisableStartupMessage bool
// RenderEngine is the interface that wraps the Render function.
RenderEngine RenderEngine
// Templates is the interface that wraps the Render function.
Templates Templates
// The amount of time allowed to read the full request including body.
ReadTimeout time.Duration // default: unlimited

10
ctx.go
View File

@ -65,8 +65,8 @@ type Cookie struct {
SameSite string
}
// RenderEngine is the interface that wraps the Render function.
type RenderEngine interface {
// Templates is the interface that wraps the Render function.
type Templates interface {
Render(io.Writer, string, interface{}) error
}
@ -717,9 +717,9 @@ func (ctx *Ctx) Render(name string, bind interface{}) (err error) {
defer bytebufferpool.Put(buf)
// Use ViewEngine if exist
if ctx.app.Settings.RenderEngine != nil {
// Render template with engine
if err := ctx.app.Settings.RenderEngine.Render(buf, name, bind); err != nil {
if ctx.app.Settings.Templates != nil {
// Render template from ViewEngine
if err := ctx.app.Settings.Templates.Render(buf, name, bind); err != nil {
return err
}
} else {