aboutsummaryrefslogtreecommitdiff
path: root/src/text/template/exec.go
diff options
context:
space:
mode:
Diffstat (limited to 'src/text/template/exec.go')
-rw-r--r--src/text/template/exec.go22
1 files changed, 11 insertions, 11 deletions
diff --git a/src/text/template/exec.go b/src/text/template/exec.go
index 8f8b5fe218..214f72d51b 100644
--- a/src/text/template/exec.go
+++ b/src/text/template/exec.go
@@ -252,7 +252,7 @@ func (s *state) walk(dot reflect.Value, node parse.Node) {
// Do not pop variables so they persist until next end.
// Also, if the action declares variables, don't print the result.
val := s.evalPipeline(dot, node.Pipe)
- if len(node.Pipe.Vars) == 0 {
+ if len(node.Pipe.Decl) == 0 {
s.printValue(node, val)
}
case *parse.IfNode:
@@ -339,11 +339,11 @@ func (s *state) walkRange(dot reflect.Value, r *parse.RangeNode) {
mark := s.mark()
oneIteration := func(index, elem reflect.Value) {
// Set top var (lexically the second if there are two) to the element.
- if len(r.Pipe.Vars) > 0 {
+ if len(r.Pipe.Decl) > 0 {
s.setTopVar(1, elem)
}
// Set next var (lexically the first if there are two) to the index.
- if len(r.Pipe.Vars) > 1 {
+ if len(r.Pipe.Decl) > 1 {
s.setTopVar(2, index)
}
s.walk(elem, r.List)
@@ -432,11 +432,11 @@ func (s *state) evalPipeline(dot reflect.Value, pipe *parse.PipeNode) (value ref
value = reflect.ValueOf(value.Interface()) // lovely!
}
}
- for _, variable := range pipe.Vars {
- if pipe.Decl {
- s.push(variable.Ident[0], value)
- } else {
+ for _, variable := range pipe.Decl {
+ if pipe.IsAssign {
s.setVar(variable.Ident[0], value)
+ } else {
+ s.push(variable.Ident[0], value)
}
}
return value
@@ -461,7 +461,7 @@ func (s *state) evalCommand(dot reflect.Value, cmd *parse.CommandNode, final ref
case *parse.PipeNode:
// Parenthesized pipeline. The arguments are all inside the pipeline; final is ignored.
return s.evalPipeline(dot, n)
- case *parse.AssignNode:
+ case *parse.VariableNode:
return s.evalVariableNode(dot, n, cmd.Args, final)
}
s.at(firstWord)
@@ -530,7 +530,7 @@ func (s *state) evalChainNode(dot reflect.Value, chain *parse.ChainNode, args []
return s.evalFieldChain(dot, pipe, chain, chain.Field, args, final)
}
-func (s *state) evalVariableNode(dot reflect.Value, variable *parse.AssignNode, args []parse.Node, final reflect.Value) reflect.Value {
+func (s *state) evalVariableNode(dot reflect.Value, variable *parse.VariableNode, args []parse.Node, final reflect.Value) reflect.Value {
// $x.Field has $x as the first ident, Field as the second. Eval the var, then the fields.
s.at(variable)
value := s.varValue(variable.Ident[0])
@@ -771,7 +771,7 @@ func (s *state) evalArg(dot reflect.Value, typ reflect.Type, n parse.Node) refle
s.errorf("cannot assign nil to %s", typ)
case *parse.FieldNode:
return s.validateType(s.evalFieldNode(dot, arg, []parse.Node{n}, missingVal), typ)
- case *parse.AssignNode:
+ case *parse.VariableNode:
return s.validateType(s.evalVariableNode(dot, arg, nil, missingVal), typ)
case *parse.PipeNode:
return s.validateType(s.evalPipeline(dot, arg), typ)
@@ -889,7 +889,7 @@ func (s *state) evalEmptyInterface(dot reflect.Value, n parse.Node) reflect.Valu
return s.idealConstant(n)
case *parse.StringNode:
return reflect.ValueOf(n.Text)
- case *parse.AssignNode:
+ case *parse.VariableNode:
return s.evalVariableNode(dot, n, nil, missingVal)
case *parse.PipeNode:
return s.evalPipeline(dot, n)