}
// allIdents returns the names of the identifiers under the Ident field of the node,
-// which might be a singleton (Identifier) or a slice (Field).
+// which might be a singleton (Identifier) or a slice (Field or Chain).
func allIdents(node parse.Node) []string {
switch node := node.(type) {
case *parse.IdentifierNode:
return []string{node.Ident}
case *parse.FieldNode:
return node.Ident
+ case *parse.ChainNode:
+ return node.Field
}
panic("unidentified node type in allIdents")
}
".X | urlquery | html | print 2 | .f 3",
[]string{"urlquery", "html"},
},
+ {
+ // covering issue 10801
+ "{{.X | js.x }}",
+ ".X | js.x | urlquery | html",
+ []string{"urlquery", "html"},
+ },
+ {
+ // covering issue 10801
+ "{{.X | (print 12 | js).x }}",
+ ".X | (print 12 | js).x | urlquery | html",
+ []string{"urlquery", "html"},
+ },
}
for i, test := range tests {
tmpl := template.Must(template.New("test").Parse(test.input))
// Wrong pipeline
{"wrong pipeline dot", "{{12|.}}", hasError, ""},
{"wrong pipeline number", "{{.|12|printf}}", hasError, ""},
- {"wrong pipeline string", "{{.|print|\"error\"}}", hasError, ""},
- {"wrong pipeline char", "{{12|print|html|'e'}}", hasError, ""},
+ {"wrong pipeline string", "{{.|printf|\"error\"}}", hasError, ""},
+ {"wrong pipeline char", "{{12|printf|'e'}}", hasError, ""},
{"wrong pipeline boolean", "{{.|true}}", hasError, ""},
{"wrong pipeline nil", "{{'c'|nil}}", hasError, ""},
{"empty pipeline", `{{printf "%d" ( ) }}`, hasError, ""},