diff --git a/pongo2_template_test.go b/pongo2_template_test.go index 6d17193..48f9235 100644 --- a/pongo2_template_test.go +++ b/pongo2_template_test.go @@ -101,27 +101,6 @@ func init() { pongo2.DefaultSet.Globals["temp_file"] = f.Name() } - -type ParentStruct struct { - name string - /* changing struct to capital letter causing another issue: - https://github.com/flosch/pongo2/issues/206 */ - Child *ChildStruct `json:"child"` -} - -type ChildStruct struct { - name string -} - -func (p *ParentStruct) String() string { - return fmt.Sprintf("
%s
", p.name) -} - -func (c *ChildStruct) String() string { - return fmt.Sprintf("

%s

", c.name) -} - - /* * End setup sandbox */ @@ -254,12 +233,6 @@ Yep!`, }, }, }, - "parent": &ParentStruct{ - name: "Parent", - Child: &ChildStruct{ - name: "Child", - }, - }, } func TestTemplate_Functions(t *testing.T) { diff --git a/template_tests/variables.tpl b/template_tests/variables.tpl index 08bac61..7a0b08d 100644 --- a/template_tests/variables.tpl +++ b/template_tests/variables.tpl @@ -13,5 +13,3 @@ {{ simple.uint|float }} {{ simple.multiple_item_list.10 }} {{ simple.multiple_item_list.4 }} - -{{ parent }} - {{ parent.name }} - {{ parent.child }} - {{ parent.child.name }} \ No newline at end of file diff --git a/template_tests/variables.tpl.out b/template_tests/variables.tpl.out index b3767a2..c795f10 100644 --- a/template_tests/variables.tpl.out +++ b/template_tests/variables.tpl.out @@ -13,5 +13,3 @@ True 8.000000 5 - -

Parent
- Parent -

Child

- Child \ No newline at end of file diff --git a/variable.go b/variable.go index 6016175..a506e37 100644 --- a/variable.go +++ b/variable.go @@ -291,23 +291,7 @@ func (vr *variableResolver) resolve(ctx *ExecutionContext) (*Value, error) { // Calling a field or key switch current.Kind() { case reflect.Struct: - field := current.FieldByName(part.s) - if !field.IsValid() && current.NumField() > 0 { - for i := 0; i < current.NumField(); i++ { - f := current.Type().Field(i) - tag := f.Tag.Get("json") - if tag != "-" { - if idx := strings.Index(tag, ","); idx != -1 { - tag = tag[:idx] - } - } - if tag == part.s { - field = current.FieldByName(f.Name) - break - } - } - } - current = field + current = current.FieldByName(part.s) case reflect.Map: current = current.MapIndex(reflect.ValueOf(part.s)) default: