Skip to content

Commit

Permalink
removed files from previous checkout
Browse files Browse the repository at this point in the history
  • Loading branch information
dgofman committed Jun 18, 2019
1 parent 987d27c commit 5f00667
Show file tree
Hide file tree
Showing 4 changed files with 1 addition and 48 deletions.
27 changes: 0 additions & 27 deletions pongo2_template_test.go
Original file line number Diff line number Diff line change
Expand Up @@ -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: <main.ChildStruct Value>
https://github.com/flosch/pongo2/issues/206 */
Child *ChildStruct `json:"child"`
}

type ChildStruct struct {
name string
}

func (p *ParentStruct) String() string {
return fmt.Sprintf("<div>%s<div>", p.name)
}

func (c *ChildStruct) String() string {
return fmt.Sprintf("<p>%s<p>", c.name)
}


/*
* End setup sandbox
*/
Expand Down Expand Up @@ -254,12 +233,6 @@ Yep!`,
},
},
},
"parent": &ParentStruct{
name: "Parent",
Child: &ChildStruct{
name: "Child",
},
},
}

func TestTemplate_Functions(t *testing.T) {
Expand Down
2 changes: 0 additions & 2 deletions template_tests/variables.tpl
Original file line number Diff line number Diff line change
Expand Up @@ -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 }}
2 changes: 0 additions & 2 deletions template_tests/variables.tpl.out
Original file line number Diff line number Diff line change
Expand Up @@ -13,5 +13,3 @@ True
8.000000

5

<div>Parent<div> - Parent - <p>Child<p> - Child
18 changes: 1 addition & 17 deletions variable.go
Original file line number Diff line number Diff line change
Expand Up @@ -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:
Expand Down

0 comments on commit 5f00667

Please sign in to comment.