On Mon, Jun 25, 2012 at 7:00 AM, Xan <[email protected]> wrote:
> Something I can access to dic itself as we pass to p.render, isn't?
Like this?
>>> d = {'x': 1, 'y': 2, 'z': 'ok'}
>>> t = jinja2.Template("Hello {% for key in dic %}{{key}}:{{dic[key]}} {%
>>> endfor %}")
>>> t.render(dic=d)
u'Hello y:2 x:1 z:ok '
You need to give the dictionary a name ("dic=d"), you can't just pass
the dictionary itself. You can also do this, which is sort of what
Juancarlo did:
>>> out = {'dic': d}
>>> t.render(out)
u'Hello y:2 x:1 z:ok '
>>> t.render(**out)
u'Hello y:2 x:1 z:ok '
>>> t.render({'dic': d})
u'Hello y:2 x:1 z:ok '
--
You received this message because you are subscribed to the Google Groups
"pocoo-libs" group.
To post to this group, send email to [email protected].
To unsubscribe from this group, send email to
[email protected].
For more options, visit this group at
http://groups.google.com/group/pocoo-libs?hl=en.