Q:

Use Variables for key in Jinja Render method

I am trying to iterate over a dictionary and then use the dictionary items to render the template using Jinja.
for key,value in dict.values()
     out = template.render(key=value)

I am using undefined=DebugUndefined so that i can use multiple template renders without overwriting the placeholders.
The issue i am facing is that Jinja expects the exact string being passed to the render and i am not able to use the dictionary key. Jinja is trying to find the text {{ key }} for replacement.
Is there a a way I can pass in a variable as the key?

A:

You have to build the dictionary and pass it as a kwargs:
out = template.render(**{key: value})

