import jinja2
env = jinja2.Environment()
t = env.from_string('{{ codes.get(mycode) }}')
next(t.generate(codes={'a': '123'}, mycode='a'))
How to get values from dictionary in jinja when key is a variable?