> render.getattr('index' + template)(ARGS)
This causes the error "no template named getattr".
Like this, it works:
return getattr(render, 'index'+template)(ARGS)
That is a bit weird and clumsy but more or less logical. At least no eval
needed :)
Branko, thanks for pointing me in the right direction.
drx
> Hm, maybe try:
>
> render.getattr('index' + template)(ARGS)
>
> I no longer use web.py, so I can't verify whether this works.
>
> On Tue, Jun 21, 2011 at 11:22 AM, Dragan Espenschied <[email protected]> wrote:
>> Dear List,
>> I have a case where I want to render a different template depending on what a
>> user did. And I couldn't find out how to render an arbitrary template in the
>> return call. Probably I am missing something very basic.
>>
>> return render.index()
>>
>> Now I have several versions of index, e.g. "index_1" or "index_2".
>>
>> This doesn't seem to work
>>
>> template = '_1'
>> return render['index' + template]()
>>
>> I know it looks embarrassing :) Please help.
>>
>> drx
>>
>> --
>> You received this message because you are subscribed to the Google Groups
>> "web.py" 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/webpy?hl=en.
>>
>>
>
>
>
--
http://noobz.cc/
http://digitalfolklore.org/
http://contemporary-home-computing.org/1tb/
--
You received this message because you are subscribed to the Google Groups
"web.py" 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/webpy?hl=en.