Jinja accessing local dictionary with key as variable from loop
578 views
Skip to first unread message
thomas.lehm...@googlemail.com
unread,
Mar 24, 2014, 2:35:14 PM3/24/14
Reply to author
Sign in to reply to author
Forward
Sign in to forward
Delete
You do not have permission to delete messages in this group
Copy link
Report message
Show original message
Either email addresses are anonymous for this group or you need the view member email addresses permission to view the original message
to ansible...@googlegroups.com
Hi,
the first line provides a dictionary of actors (names). The values are a list of movies. In a loop over a movie and there over each actor I want to know in how many movies an actor plays a role. I'm not able to access the dictionary ...
... I tried actors[actor] as well as actors.get(actor) but
{% set actors = page.statistic.getActorsAsDictionary() %} .... {{ actors.get(actor)|length }} => yells about NoneType {{ actors[actor]|length }} => always 0
I tried it this way: {% set actors = {"Dennis Quaid": [1]} %} {{ actors[actor]|length }} => always 0
It DOES work for: {% set actors = {"Dennis Quaid": [1234]} %} {{ actors["Dennis Quaid"]|length }} => is "1"