diff --git a/NOTICE b/NOTICE index 5da165b6..637cab68 100644 --- a/NOTICE +++ b/NOTICE @@ -101,9 +101,9 @@ Revision ID: 5fc50a00491616d5cd0cbce3abd8b699838e25ca toml 3012a1dbe2e4bd1 https://github.com/BurntSushi/toml 391d42b32f0577c b7bbc7f005 - jwt e87a84e0681e206 https://github.com/kataras/jwt - f3733932450e25d - 7747daf215 + jwt 933b4a74659b074 https://github.com/kataras/jwt + 00070920d0700b9 + 63fa545d6c uuid cb32006e483f2a2 https://github.com/google/uuid 3230e24209cf185 c65b477dbf diff --git a/go.mod b/go.mod index 93e5e106..c9ee4e1e 100644 --- a/go.mod +++ b/go.mod @@ -11,7 +11,7 @@ require ( github.com/dgraph-io/badger/v2 v2.2007.2 github.com/eknkc/amber v0.0.0-20171010120322-cdade1c07385 github.com/fatih/structs v1.1.0 - github.com/flosch/pongo2/v4 v4.0.0 + github.com/flosch/pongo2/v4 v4.0.1 github.com/go-redis/redis/v8 v8.4.0 github.com/google/uuid v1.1.2 github.com/hashicorp/go-version v1.2.1 @@ -21,7 +21,7 @@ require ( github.com/json-iterator/go v1.1.10 github.com/kataras/blocks v0.0.4 github.com/kataras/golog v0.1.5 - github.com/kataras/jwt v0.0.6 + github.com/kataras/jwt v0.0.7 github.com/kataras/neffos v0.0.18 github.com/kataras/pio v0.0.10 github.com/kataras/sitemap v0.0.5 diff --git a/view/django.go b/view/django.go index 2f8bc4c8..9922f363 100644 --- a/view/django.go +++ b/view/django.go @@ -12,6 +12,7 @@ import ( "github.com/kataras/iris/v12/context" + "github.com/fatih/structs" "github.com/flosch/pongo2/v4" ) @@ -261,15 +262,19 @@ func getPongoContext(templateData interface{}) pongo2.Context { return nil } - if contextData, isPongoContext := templateData.(pongo2.Context); isPongoContext { - return contextData - } + switch data := templateData.(type) { + case pongo2.Context: + return data + case context.Map: + return pongo2.Context(data) + default: + // if struct, convert it to map[string]interface{} + if structs.IsStruct(data) { + return pongo2.Context(structs.Map(data)) + } - if contextData, isContextViewData := templateData.(context.Map); isContextViewData { - return pongo2.Context(contextData) + panic("django: template data: should be a map or struct") } - - return templateData.(map[string]interface{}) } func (s *DjangoEngine) fromCache(relativeName string) *pongo2.Template {