Instead of passing variables to a template like so:
template.render(var1='hello', var2='world')
How can I pass a dictionary to the template and have it render in the same manner
vars = {'var1': 'hello', 'var2': 'world'}
so in the template I can display the variables as normal:
${var1} ${var2}
I don't want any extra c开发者_C百科ode in the template so I was thinking of using the Context object somehow, but I have hit a brick wall. Any ideas?
I don't know mako, but to use a dict as keyword arguments (or kwargs), you have to prepend two *
:
template.render(**vars)
精彩评论