If "steps" is a dict, use steps[key]:

>>> t = jinja2.Template("{{steps[step_name].step}}")
>>> t.render(steps={'default': {'step': 'the content'}, 'custom': {'step':
'custom content'}}, step_name='default')
u'the content'

https://docs.python.org/3.4/tutorial/datastructures.html#dictionaries

-Steve

On Mon, Jan 5, 2015 at 7:46 AM, Barry <[email protected]> wrote:

> If I have the following variables:
>
> steps:
>   default:
>     step: the content
>   custom:
>     step: custom content
> step_name: default
>
>
> how can I make "the content" appear in a template by referring to "
> step_name"? I had hoped "{{ steps.{{ step_name }}.step }}" might work,
> but I get a parse error. I need some way of accessing a variable by name at
> runtime. How can I do this?
>
> Barry
>
> --
> You received this message because you are subscribed to the Google Groups
> "pocoo-libs" group.
> To unsubscribe from this group and stop receiving emails from it, send an
> email to [email protected].
> To post to this group, send email to [email protected].
> Visit this group at http://groups.google.com/group/pocoo-libs.
> For more options, visit https://groups.google.com/d/optout.
>

-- 
You received this message because you are subscribed to the Google Groups 
"pocoo-libs" group.
To unsubscribe from this group and stop receiving emails from it, send an email 
to [email protected].
To post to this group, send email to [email protected].
Visit this group at http://groups.google.com/group/pocoo-libs.
For more options, visit https://groups.google.com/d/optout.

Reply via email to