Commit 13bb28a4 authored by Russ Cox's avatar Russ Cox

template: fix handling of pointer inside interface

R=r
CC=golang-dev
https://golang.org/cl/982043
parent 6f33f34b
......@@ -596,7 +596,7 @@ func (st *state) findVar(s string) reflect.Value {
return nil
}
if intf, ok := data.(*reflect.InterfaceValue); ok {
data = intf.Elem()
data = reflect.Indirect(intf.Elem())
}
switch typ := data.Type().(type) {
......
......@@ -48,6 +48,7 @@ type S struct {
stringmap map[string]string
bytes []byte
iface interface{}
ifaceptr interface{}
}
func (s *S) pointerMethod() string { return "ptrmethod!" }
......@@ -385,6 +386,11 @@ var tests = []*Test{
out: "[1 2 3]",
},
&Test{
in: "{.section ifaceptr}{item} {value}{.end}",
out: "Item Value",
},
}
func TestAll(t *testing.T) {
......@@ -423,6 +429,7 @@ func testAll(t *testing.T, parseFunc func(*Test) (*Template, os.Error)) {
s.stringmap["stringkey2"] = "stringresult"
s.bytes = []byte("hello")
s.iface = []int{1, 2, 3}
s.ifaceptr = &T{"Item", "Value"}
var buf bytes.Buffer
for _, test := range tests {
......
Markdown is supported
0% or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment