Using Templates how can I get list parameters that are defined in a template. For example if I have the template:
t, _ := template.New("template_name").Parse("<h1>{{.title}}</h1>r{{.release}}")
How can I get title
and release
? I intend to iterate over list of parameters and search them in multiple locations. How this could be done is not clear from the template documentation.
I would assume you could walk through the parse.Tree that is inside both html/template.Template as well as text/template.Template. You'd have to check every node in the tree recursively to see if it's a FieldNode or not (and I don't really know, how variables defined within a template - like in a range operator - are handled). If all fields are as simple as in your example, you could probably just plain-text search your template ... ;o)