]> Cypherpunks repositories - gostls13.git/commit
text/template: allow .Field access to parenthesized expressions
authorRob Pike <r@golang.org>
Mon, 24 Sep 2012 03:23:15 +0000 (13:23 +1000)
committerRob Pike <r@golang.org>
Mon, 24 Sep 2012 03:23:15 +0000 (13:23 +1000)
commit9050550c12e2d09cf8f0c22a270cfa90120cdf6d
tree014cb848c742805de43d7d3f5293e830af2baef6
parentedce6349639e321c3b1a34036a8fbc08ad363cd3
text/template: allow .Field access to parenthesized expressions

Change the grammar so that field access is a proper operator.
This introduces a new node, ChainNode, into the public (but
actually internal) API of text/template/parse. For
compatibility, we only use the new node type for the specific
construct, which was not parseable before. Therefore this
should be backward-compatible.

Before, .X.Y was a token in the lexer; this CL breaks it out
into .Y applied to .X. But for compatibility we mush them
back together before delivering. One day we might remove
that hack; it's the simple TODO in parse.go/operand.

This change also provides grammatical distinction between
        f
and
        (f)
which might permit function values later, but not now.

Fixes #3999.

R=golang-dev, dsymonds, gri, rsc, mikesamuel
CC=golang-dev
https://golang.org/cl/6494119
src/pkg/html/template/escape_test.go
src/pkg/text/template/doc.go
src/pkg/text/template/exec.go
src/pkg/text/template/exec_test.go
src/pkg/text/template/parse/lex.go
src/pkg/text/template/parse/lex_test.go
src/pkg/text/template/parse/node.go
src/pkg/text/template/parse/parse.go
src/pkg/text/template/parse/parse_test.go