Probably been learning too much Python today. Excuse the tired newbie question.
Trying to use py2neo with flask templates (which are just WTForms with some extensions, which is using Jinja).
If I do a
mylist = graph.run ("MATCH (n:Things) return n")
render_template ( "somelist.html", mylist = mylist)
Then in the template I have to do
{% for thing in mylist %}
I can use the ".data()" function and "n.name as name, n.attribute as attribute" in the Cypher to get rid of the Cypher variable "n". But that is ugly and inflexible if I introduce another attribute to "thing"s.
Is there a "tidy" or normal way to "lose the cypher variable n"? So that the template doesn't need to know the structure of the Cypher result?
My queries are actually more complex so "run" is necessary (afaict), and I expect to be returning nodes of different types on some occasions, so it may make sense to lose the cypher variable very late, such as immediately before the "render_template" call. But having decided I want to render a bunch of "thing"s, I want to decouple the template from the Cypher query variable, so I just need to know the attributes of the node type in the template.