Skip to content
GitLab
Projects
Groups
Snippets
Help
Loading...
Help
Help
Support
Community forum
Keyboard shortcuts
?
Submit feedback
Contribute to GitLab
Sign in / Register
Toggle navigation
Open sidebar
Kirill Smelkov
go
Commits
d6ad6f0e
Commit
d6ad6f0e
authored
13 years ago
by
Rob Pike
Browse files
Options
Download
Email Patches
Plain Diff
text/template: variables do not take arguments
R=golang-dev, dsymonds CC=golang-dev
https://golang.org/cl/5821044
parent
b5021f3f
Changes
2
Hide whitespace changes
Inline
Side-by-side
Showing
2 changed files
with
5 additions
and
0 deletions
+5
-0
src/pkg/text/template/exec.go
src/pkg/text/template/exec.go
+1
-0
src/pkg/text/template/exec_test.go
src/pkg/text/template/exec_test.go
+4
-0
No files found.
src/pkg/text/template/exec.go
View file @
d6ad6f0e
...
...
@@ -369,6 +369,7 @@ func (s *state) evalVariableNode(dot reflect.Value, v *parse.VariableNode, args
// $x.Field has $x as the first ident, Field as the second. Eval the var, then the fields.
value
:=
s
.
varValue
(
v
.
Ident
[
0
])
if
len
(
v
.
Ident
)
==
1
{
s
.
notAFunction
(
args
,
final
)
return
value
}
return
s
.
evalFieldChain
(
dot
,
value
,
v
.
Ident
[
1
:
],
args
,
final
)
...
...
This diff is collapsed.
Click to expand it.
src/pkg/text/template/exec_test.go
View file @
d6ad6f0e
...
...
@@ -466,6 +466,10 @@ var execTests = []execTest{
{
"bug6b"
,
"{{vfunc .V0 .V0}}"
,
"vfunc"
,
tVal
,
true
},
{
"bug6c"
,
"{{vfunc .V1 .V0}}"
,
"vfunc"
,
tVal
,
true
},
{
"bug6d"
,
"{{vfunc .V1 .V1}}"
,
"vfunc"
,
tVal
,
true
},
// Legal parse but illegal execution: non-function should have no arguments.
{
"bug7a"
,
"{{3 2}}"
,
""
,
tVal
,
false
},
{
"bug7b"
,
"{{$x := 1}}{{$x 2}}"
,
""
,
tVal
,
false
},
{
"bug7c"
,
"{{$x := 1}}{{3 | $x}}"
,
""
,
tVal
,
false
},
}
func
zeroArgs
()
string
{
...
...
This diff is collapsed.
Click to expand it.
Write
Preview
Markdown
is supported
0%
Try again
or
attach a new file
.
Attach a file
Cancel
You are about to add
0
people
to the discussion. Proceed with caution.
Finish editing this message first!
Cancel
Please
register
or
sign in
to comment