diff options
| author | Rob Pike <r@golang.org> | 2012-04-23 15:39:02 +1000 |
|---|---|---|
| committer | Rob Pike <r@golang.org> | 2012-04-23 15:39:02 +1000 |
| commit | a8098cbcfd7772911f761e787f656f6e685c105e (patch) | |
| tree | 2bc028cbce7a7aca47d1855b3ab4031bc2cf037e /src/pkg/text/template/parse/parse.go | |
| parent | 53372903c70e93704cc32dc229d8d83a03bcc457 (diff) | |
| download | go-a8098cbcfd7772911f761e787f656f6e685c105e.tar.xz | |
text/template: detect unexported fields better
Moves the error detection back into execution, where it used to be,
and improves the error message.
Rolls back most of 6009048, which broke lower-case keys in maps.
If it weren't for maps we could detect this at compile time rather than
execution time.
Fixes #3542.
R=golang-dev, dsymonds
CC=golang-dev
https://golang.org/cl/6098051
Diffstat (limited to 'src/pkg/text/template/parse/parse.go')
| -rw-r--r-- | src/pkg/text/template/parse/parse.go | 10 |
1 files changed, 0 insertions, 10 deletions
diff --git a/src/pkg/text/template/parse/parse.go b/src/pkg/text/template/parse/parse.go index cbb1686a7f..7970b5fcc6 100644 --- a/src/pkg/text/template/parse/parse.go +++ b/src/pkg/text/template/parse/parse.go @@ -14,7 +14,6 @@ import ( "runtime" "strconv" "unicode" - "unicode/utf8" ) // Tree is the representation of a single parsed template. @@ -474,9 +473,6 @@ Loop: case itemVariable: cmd.append(t.useVar(token.val)) case itemField: - if !isExported(token.val) { - t.errorf("field %q not exported; cannot be evaluated", token.val) - } cmd.append(newField(token.val)) case itemBool: cmd.append(newBool(token.val == "true")) @@ -502,12 +498,6 @@ Loop: return cmd } -// isExported reports whether the field name (which starts with a period) can be accessed. -func isExported(fieldName string) bool { - r, _ := utf8.DecodeRuneInString(fieldName[1:]) // drop the period - return unicode.IsUpper(r) -} - // hasFunction reports if a function name exists in the Tree's maps. func (t *Tree) hasFunction(name string) bool { for _, funcMap := range t.funcs { |
