mirror of
https://github.com/volatiletech/authboss.git
synced 2024-11-24 08:42:17 +02:00
Fix template does not exists panic
This commit is contained in:
parent
f5cbe61cc9
commit
ea6cb83297
@ -74,7 +74,7 @@ func LoadTemplates(ab *authboss.Authboss, layout *template.Template, fpath strin
|
||||
func (t Templates) Render(ctx *authboss.Context, w http.ResponseWriter, r *http.Request, name string, data authboss.HTMLData) error {
|
||||
tpl, ok := t[name]
|
||||
if !ok {
|
||||
return authboss.RenderErr{TemplateName: tpl.Name(), Data: data, Err: ErrTemplateNotFound}
|
||||
return authboss.RenderErr{TemplateName: name, Data: data, Err: ErrTemplateNotFound}
|
||||
}
|
||||
|
||||
data.MergeKV(
|
||||
|
@ -75,6 +75,12 @@ func TestTemplates_Render(t *testing.T) {
|
||||
"hello": testViewTemplate,
|
||||
}
|
||||
|
||||
// Make sure that we will see an error when template does not exists
|
||||
errTemplateNotFound := tpls.Render(ctx, w, r, "helloNotExists", authboss.HTMLData{"external": "there"})
|
||||
if errTemplateNotFound == nil {
|
||||
t.Error("Expected error when template does not exists")
|
||||
}
|
||||
|
||||
err := tpls.Render(ctx, w, r, "hello", authboss.HTMLData{"external": "there"})
|
||||
if err != nil {
|
||||
t.Error(err)
|
||||
|
Loading…
Reference in New Issue
Block a user