]> Cypherpunks repositories - gostls13.git/commit
text/template: add support for reflect.Value args, results in funcs
authorRuss Cox <rsc@golang.org>
Wed, 19 Oct 2016 13:11:16 +0000 (09:11 -0400)
committerRuss Cox <rsc@golang.org>
Wed, 19 Oct 2016 18:20:35 +0000 (18:20 +0000)
commit5378dd77684e2eee5f05aab4b77497bb635fd544
tree19726011b7167528fd9d290bf396cbc389281a30
parentd2aa8601b5aafa9736f8e49ca713ecc31f9a011f
text/template: add support for reflect.Value args, results in funcs

Add support for passing reflect.Values to and returning reflect.Values from
any registered functions in the FuncMap, much as if they were
interface{} values. Keeping the reflect.Value instead of round-tripping
to interface{} preserves addressability of the value, which is important
for method lookup.

Change index and a few other built-in functions to use reflect.Values,
making a loop using explicit indexing now match the semantics that
range has always had.

Fixes #14916.

Change-Id: Iae1a2fd9bb426886a7fcd9204f30a2d6ad4646ad
Reviewed-on: https://go-review.googlesource.com/31462
Reviewed-by: Rob Pike <r@golang.org>
src/text/template/exec.go
src/text/template/exec_test.go
src/text/template/funcs.go