From 62a1829cb9cdaf179229abed599276b08c617f3e Mon Sep 17 00:00:00 2001 From: "Gerasimos (Makis) Maropoulos" Date: Sun, 26 Dec 2021 00:01:01 +0200 Subject: [PATCH] :christmas_tree: Merry Christmas everyone minor fixes --- aliases.go | 8 ++++++++ view/amber.go | 4 ++-- view/django.go | 2 +- view/handlebars.go | 8 ++++++-- view/html.go | 4 ++-- view/view.go | 2 +- 6 files changed, 20 insertions(+), 8 deletions(-) diff --git a/aliases.go b/aliases.go index eca05047..e422ddf6 100644 --- a/aliases.go +++ b/aliases.go @@ -44,6 +44,14 @@ type ( // // Example: https://github.com/kataras/iris/blob/master/_examples/request-body/read-custom-via-unmarshaler/main.go UnmarshalerFunc = context.UnmarshalerFunc + // DecodeFunc is a generic type of decoder function. + // When the returned error is not nil the decode operation + // is terminated and the error is received by the ReadJSONStream method, + // otherwise it continues to read the next available object. + // Look the `Context.ReadJSONStream` method. + // + // Example: https://github.com/kataras/iris/blob/master/_examples/request-body/read-json-stream. + DecodeFunc = context.DecodeFunc // A Handler responds to an HTTP request. // It writes reply headers and data to the Context.ResponseWriter() and then return. // Returning signals that the request is finished; diff --git a/view/amber.go b/view/amber.go index 1bda5e1a..60aec742 100644 --- a/view/amber.go +++ b/view/amber.go @@ -217,7 +217,7 @@ func (s *AmberEngine) executeTemplateBuf(name string, binding interface{}) (stri tmpl := s.fromCache(name) if tmpl == nil { s.bufPool.Put(buf) - return "", ErrNotExist{name, false, binding} + return "", ErrNotExist{Name: name, IsLayout: false, Data: binding} } err := tmpl.ExecuteTemplate(buf, name, binding) @@ -253,5 +253,5 @@ func (s *AmberEngine) ExecuteWriter(w io.Writer, filename string, layout string, return tmpl.Execute(w, bindingData) } - return ErrNotExist{filename, false, bindingData} + return ErrNotExist{Name: filename, IsLayout: false, Data: bindingData} } diff --git a/view/django.go b/view/django.go index 8d6b7d6a..f0ba57b9 100644 --- a/view/django.go +++ b/view/django.go @@ -307,5 +307,5 @@ func (s *DjangoEngine) ExecuteWriter(w io.Writer, filename string, _ string, bin return tmpl.ExecuteWriter(getPongoContext(bindingData), w) } - return ErrNotExist{filename, false, bindingData} + return ErrNotExist{Name: filename, IsLayout: false, Data: bindingData} } diff --git a/view/handlebars.go b/view/handlebars.go index a226f21c..22adab8d 100644 --- a/view/handlebars.go +++ b/view/handlebars.go @@ -212,7 +212,7 @@ func (s *HandlebarsEngine) ExecuteWriter(w io.Writer, filename string, layout st if m, is := binding.(map[string]interface{}); is { // handlebars accepts maps, context = m } else { - return fmt.Errorf("Please provide a map[string]interface{} type as the binding instead of the %#v", binding) + return fmt.Errorf("please provide a map[string]interface{} type as the binding instead of the %#v", binding) } contents, err := s.executeTemplateBuf(filename, binding) @@ -235,5 +235,9 @@ func (s *HandlebarsEngine) ExecuteWriter(w io.Writer, filename string, layout st return err } - return ErrNotExist{fmt.Sprintf("%s (file: %s)", renderFilename, filename), false, bindingData} + return ErrNotExist{ + Name: fmt.Sprintf("%s (file: %s)", renderFilename, filename), + IsLayout: false, + Data: bindingData, + } } diff --git a/view/html.go b/view/html.go index 151b9990..a08a6094 100644 --- a/view/html.go +++ b/view/html.go @@ -421,14 +421,14 @@ func (s *HTMLEngine) ExecuteWriter(w io.Writer, name string, layout string, bind t := s.Templates.Lookup(name) if t == nil { - return ErrNotExist{name, false, bindingData} + return ErrNotExist{Name: name, IsLayout: false, Data: bindingData} } s.runtimeFuncsFor(t, name, bindingData) if layout = getLayout(layout, s.layout); layout != "" { lt := s.Templates.Lookup(layout) if lt == nil { - return ErrNotExist{layout, true, bindingData} + return ErrNotExist{Name: layout, IsLayout: true, Data: bindingData} } s.layoutFuncsFor(lt, name, bindingData) diff --git a/view/view.go b/view/view.go index 86acf3b8..49a83868 100644 --- a/view/view.go +++ b/view/view.go @@ -79,7 +79,7 @@ func (v *View) AddFunc(funcName string, funcBody interface{}) { // Load compiles all the registered engines. func (v *View) Load() error { if !v.Registered() { - return fmt.Errorf("No engine is registered") + return fmt.Errorf("no engine was registered") } return v.Engine.Load() }