🎄 Merry Christmas everyone

minor fixes
This commit is contained in:
Gerasimos (Makis) Maropoulos 2021-12-26 00:01:01 +02:00
parent e213dba0d3
commit 62a1829cb9
No known key found for this signature in database
GPG Key ID: 66FCC29BD385FCA6
6 changed files with 20 additions and 8 deletions

View File

@ -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;

View File

@ -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}
}

View File

@ -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}
}

View File

@ -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,
}
}

View File

@ -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)

View File

@ -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()
}